Copyright (C) 2000-2012 |
GNU Info (mysql.info)Automatic startStarting and Stopping MySQL Automatically ----------------------------------------- The `mysql.server' and `safe_mysqld' scripts can be used to start the server automatically at system startup time. `mysql.server' can also be used to stop the server. The `mysql.server' script can be used to start or stop the server by invoking it with `start' or `stop' arguments: shell> mysql.server start shell> mysql.server stop `mysql.server' can be found in the `share/mysql' directory under the MySQL installation directory or in the `support-files' directory of the MySQL source tree. Before `mysql.server' starts the server, it changes directory to the MySQL installation directory, then invokes `safe_mysqld'. You might need to edit `mysql.server' if you have a binary distribution that you've installed in a non-standard location. Modify it to `cd' into the proper directory before it runs `safe_mysqld'. If you want the server to run as some specific user, add an appropriate `user' line to the `/etc/my.cnf' file, as shown later in this section. `mysql.server stop' brings down the server by sending a signal to it. You can take down the server manually by executing `mysqladmin shutdown'. You might want to add these start and stop commands to the appropriate places in your `/etc/rc*' files when you start using MySQL for production applications. Note that if you modify `mysql.server', then upgrade MySQL sometime, your modified version will be overwritten, so you should make a copy of your edited version that you can reinstall. If your system uses `/etc/rc.local' to start external scripts, you should append the following to it: /bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &' You can also add options for `mysql.server' in a global `/etc/my.cnf' file. A typical `/etc/my.cnf' file might look like this: [mysqld] datadir=/usr/local/mysql/var socket=/var/tmp/mysql.sock port=3306 user=mysql [mysql.server] basedir=/usr/local/mysql The `mysql.server' script understands the following options: `datadir', `basedir', and `pid-file'. The following table shows which option groups each of the startup scripts read from option files: *Script* *Option groups* `mysqld' `mysqld' and `server' `mysql.server' `mysql.server', `mysqld', and `server' `safe_mysqld' `mysql.server', `mysqld', and `server' Note: Option files. automatically generated by info2www version 1.2.2.9 |