如何重新启动 mysql 以及 my.cnf 文件在哪里

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2743861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 15:56:20  来源:igfitidea点击:

How do I restart mysql and where is my.cnf file

mysql

提问by Nick Vanderbilt

I am using a Mac OS X Snow Leopard Apple computer.

我使用的是 Mac OS X Snow Leopard Apple 电脑。

I installed MySQL on my machine using instructions mentioned here. Everything works great. However I have two questions.

我使用这里提到的说明在我的机器上安装了 MySQL 。一切都很好。不过我有两个问题。

  1. Where is my.cnffile? I searched the whole file system and result is empty. Is it possible that there is no my.cnfand MySQL works with default values. If yes then probably I should create my.cnfat /etc/mysql. Is that right?

  2. How do I restart the MySQL server ? I know it gets started when I restart my machine. Here is what plist looks like. mysqld_safedoes not let me restart server.

    KeepAlive Label com.mysql.mysqld Program /usr/local/mysql/bin/mysqld_safe RunAtLoad UserName mysql WorkingDirectory /usr/local/mysql

  1. my.cnf档案在哪里?我搜索了整个文件系统,结果是空的。是否有可能没有my.cnf并且 MySQL 使用默认值。如果是,那么我可能应该my.cnf/etc/mysql. 那正确吗?

  2. 如何重新启动 MySQL 服务器?我知道当我重新启动机器时它会启动。这是 plist 的样子。mysqld_safe不允许我重新启动服务器。

    KeepAlive 标签 com.mysql.mysqld 程序 /usr/local/mysql/bin/mysqld_safe RunAtLoad 用户名 mysql 工作目录 /usr/local/mysql

回答by Keith Randall

From the example my.cnf that comes with mysql:

从mysql自带的例子my.cnf:

# You can copy this file to
# /etc/my.cnf to set global options,
# mysql-data-dir/my.cnf to set server-specific options (in this
# installation this directory is /usr/local/mysql/data) or
# ~/.my.cnf to set user-specific options.

On my OS X 10.4 instance, my.cnf is at /etc/my.cnf.

在我的 OS X 10.4 实例上,my.cnf 位于 /etc/my.cnf。

To restart mysql, use mysqladmin to shut it down and then start it up again with mysqld_safe:

要重新启动 mysql,请使用 mysqladmin 将其关闭,然后使用 mysqld_safe 再次启动它:

/usr/local/mysql/bin/mysqladmin -uroot -p shutdown
sudo /usr/local/mysql/bin/mysqld_safe &

回答by anonymous coward

You haven't told us what OS you're on, but the defaults on Debian Linux are:

您还没有告诉我们您使用的是什么操作系统,但 Debian Linux 上的默认设置是:

/etc/init.d/mysql restart

for restart, and the my.cnffile is located at /etc/mysql/my.cnf

重新启动,my.cnf文件位于/etc/mysql/my.cnf

回答by NeuroScr

  1. It possible it doesn't exist. You can create one in /etc/my.cnfor in your datadir(usually /var/lib/mysqlor /usr/local/var).

  2. I usually use mysqladmin shutdown(might need a -pif you have a password set) and then a sudo mysqld_safe &to start it up.

  1. 它可能不存在。您可以/etc/my.cnf在您的datadir(通常/var/lib/mysql/usr/local/var)中或中创建一个。

  2. 我通常使用mysqladmin shutdown-p如果您设置了密码,可能需要一个)然后使用 asudo mysqld_safe &来启动它。