Because the MySQL server has a variety of installation distributions and can run on a variety of operating platforms, it has a variety of ways to start and stop. You can use one of these according to the actual situation. When you install, upgrade, or maintain your system, you may need to start and terminate the server multiple times, and you need to know everything about starting and terminating the server.
Run Daemons directly
1, you can use the method
In general, you can have the following options to start the MySQL server, their functions and usage is almost the same, so together here to introduce:
Direct use of the MySQL daemon mysqld to start the database system, especially on the Win32 platform, because server scripts such as Mysql.server are not available on the Win32 platform.
By calling the Safe_mysqld script, it accepts the same parameters as mysqld and tries to determine the correct options for mysqld and then chooses to run it with those.
2. Where the script or daemon resides
For the installation of binary distribution, the MYSQLD daemon is installed in the bin directory of the MySQL installation directory, or it can be found in the MySQL source code distribution libexec directory, the default is/usr/local/libexec/. For RPM distributions, mysqld should be in the program search path determined by the path variable, so it can be referenced directly.
Safe_mysqld is still a script and exists only in the distribution of UNIX platforms. The Safe_mysqld script is installed in the bin directory of the MySQL installation directory, or can be found in the MySQL source code distribution scripts directory. For RPM distribution, the script should be in the program search path determined by the path variable, so it can be referenced directly.
3, why to use the Safe_mysqld script
Safe_mysqld accepts and mysqld the same parameters and attempts to determine the location of the server program and database directory, and then uses these locations to invoke the server. Safe_mysqld redirects the server's standard error output to an error file in the database directory and exists as a record. After the server is started, SAFE_MYSQLD also monitors the server and restarts it when it dies. Safe_mysqld is typically used in the BSD-style version of UNIX.
If you have ever started safe_mysqld for root or in the System launcher, the error log will have root. Calling Safe_mysqld with an unprivileged user identity may cause an error in Access Denied (that is, "ownership denied"). You can delete the error file at this time and try again.
Because of the functionality of the Safe_mysqld script, using the Safe_mysqld script is significantly more effective than starting the mysqld daemon directly.
4, the full process of starting the server
For distribution on UNIX platforms, if you start sqfe_mysqld with root or during system boot, the error log is owned by root, which may cause "permission denied" when you later attempt to invoke Safe_mysqld with an unprivileged user (Permission denied) error, delete error log try again. Therefore, it is recommended that you first switch to a dedicated user MySQL before starting the server.
The specific methods are as follows:
UNIX Platform
$ su MySQL
$ safe_mysql & (or Mysqld &, not recommended)
Win32 Platform
C: \ mysql\bin>mysqld--standalone
or C: \ Mysql\bin>mysqld-nt–standalone
If you use mysqld and do not install MySQL in a standard location, you usually need to provide the-BASEDIR option for your database installation location.
$safe _mysqld--basedir= "/path/to/mysql" & (Unix platform)
C:\mysql\bin>mysqld--basedir= "X:/path/to/mysql" (Win32 platform)