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

时间:2021-06-16 07:06:54

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.cnf file? I searched the whole file system and result is empty. Is it possible that there is no my.cnf and MySQL works with default values. If yes then probably I should create my.cnf at /etc/mysql. Is that right?

    my.cnf文件在哪里?我搜索了整个文件系统,结果为空。是否有可能没有my.cnf和MySQL使用默认值。如果是,那么我可能应该在/ etc / mysql创建my.cnf。是对的吗?

  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_safe does not let me restart server.

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

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

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

3 个解决方案

#1


8  

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 &

#2


2  

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

#3


2  

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

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

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

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

#1


8  

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 &

#2


2  

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

#3


2  

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

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

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

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