[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
Generally, you start the mysqld
server in one of these ways:
mysqld
directly. This works on any platform.
mysql.server
. This script is used primarily at
system startup and shutdown on systems that use System V-style run
directories. It is described more fully later in this section.
mysqld_safe
, which tries to determine the proper options
for mysqld
and then runs it with those options. This script is
used on systems based on BSD Unix. It also is invoked by mysql.server
.
See section mysqld_safe
.
The mysql.server
and mysqld_safe
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.
Note that if you use the Linux RPM package
(MySQL-server-VERSION.rpm
), the mysql.server
script has
already been installed as `/etc/init.d/mysql'. You don't have to
install it manually. See 2.2.2 Installing MySQL on Linux for more information on the
Linux RPM packages.
On Mac OS X, you can install a separate MySQL Startup Item package to enable the automatic startup of MySQL on system bootup. See 2.2.3 Installing MySQL on Mac OS X for details.
Before mysql.server
starts the server, it changes the directory to
the MySQL installation directory, then invokes mysqld_safe
.
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 mysqld_safe
. 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 also stop the server manually by executing
mysqladmin shutdown
.
You need to add these start and stop commands to the appropriate places in your `/etc/rc*' files when you want to start up MySQL automatically on your server.
On most current Linux distributions, it is sufficient to copy the file
mysql.server
into the `/etc/init.d' directory (or
`/etc/rc.d/init.d' on older Red Hat systems). Afterwards, run the
following command to enable the startup of MySQL on system bootup:
shell> chkconfig --add mysql.server |
On FreeBSD startup scripts generally should go in
`/usr/local/etc/rc.d/'. The rc(8)
manual page also states that
scripts in this directory are only executed, if their basename matches the
shell globbing pattern *.sh
. Any other files or directories present
within the directory are silently ignored. In other words, on FreeBSD you
should install the file `mysql.server' as
`/usr/local/etc/rc.d/mysql.server.sh' to enable automatic startup.
As an alternative to the above, some operating systems also use `/etc/rc.local' or `/etc/init.d/boot.local' to start additional services on bootup. To start up MySQL using this method, you could append something like the following to it:
/bin/sh -c 'cd /usr/local/mysql; ./bin/mysqld_safe --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 startup script reads from option files:
Script | Option groups |
mysqld | [mysqld] , [server] and [mysqld-major-version] |
mysql.server | [mysql.server] , [mysqld] , and [server] |
mysqld_safe | [mysqld] , [server] , and [mysqld_safe] |
For backward compatibility, mysql.server
also reads the
[mysql_server]
group and mysqld_safe
also reads the
[safe_mysqld]
group. However, you should update your option
files to use the [mysql.server]
and [mysqld_safe]
groups instead.
See section 4.3.2 Using Option Files.
[ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |