如何重新启动 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
How do I restart mysql and where is my.cnf file
提问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 。一切都很好。不过我有两个问题。
Where is
my.cnf
file? I searched the whole file system and result is empty. Is it possible that there is nomy.cnf
and MySQL works with default values. If yes then probably I should createmy.cnf
at/etc/mysql
. Is that right?How do I restart the MySQL server ? I know it gets started when I restart my machine. Here is what plist looks like.
mysqld_safe
does not let me restart server.KeepAlive Label com.mysql.mysqld Program /usr/local/mysql/bin/mysqld_safe RunAtLoad UserName mysql WorkingDirectory /usr/local/mysql
my.cnf
档案在哪里?我搜索了整个文件系统,结果是空的。是否有可能没有my.cnf
并且 MySQL 使用默认值。如果是,那么我可能应该my.cnf
在/etc/mysql
. 那正确吗?如何重新启动 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.cnf
file is located at /etc/mysql/my.cnf
重新启动,my.cnf
文件位于/etc/mysql/my.cnf
回答by NeuroScr
It possible it doesn't exist. You can create one in
/etc/my.cnf
or in yourdatadir
(usually/var/lib/mysql
or/usr/local/var
).I usually use
mysqladmin shutdown
(might need a-p
if you have a password set) and then asudo mysqld_safe &
to start it up.
它可能不存在。您可以
/etc/my.cnf
在您的datadir
(通常/var/lib/mysql
或/usr/local/var
)中或中创建一个。我通常使用
mysqladmin shutdown
(-p
如果您设置了密码,可能需要一个)然后使用 asudo mysqld_safe &
来启动它。