There are many ways to start MySQL, we will discuss it in one by one
One, mysqld
Mysqld is a MySQL service
Mysqld the [mysqld] and [Server] group groups in the My.cnf file when it is started this way
(Each group has [] to split)
In general, we manually invoke mysqld in this way, and if it is not for the purpose of debugging, we generally do not do so.
Because this way, the error log is exported directly from the terminal, rather than in the error log file, so if MySQL crashes
And we don't know why.
Connection method
Start
[Root@test4 ~]#/usr/local/mysql/libexec/mysqld--defaults-file=/etc/my.cnf--user=mysql 130617 7:22:58 [note] Eve NT scheduler:loaded 0 Events 130617 7:22:58 [note]/usr/local/mysql/libexec/mysqld:ready for connections. Version: ' 5.1.70-log ' socket: '/tmp/mysql.sock ' port:3306 Source distribution
[Root@test4 ~]# PS aux|grep mysql mysql 19327 0.0 1.3 125304 6648 pts/0 sl+ 07:22 Exec/mysqld--defaults-file=/etc/my.cnf--user=mysql
Connnect
Mysqld--defaults-file=/etc/my.cnf
Mysqld-s/tmp/mysql.sock
Second, Mysqld_safe
Mysqld_safe will read the [Mysqld],[server] and [Mysqld_safe] group groups in the My.cnf file when it is started in this way, but it will also read [safe_mysqld] for compatibility.
Mysqld_safe is a shell script that calls Mysqld, and it also sets an error log that can start the mysqld and monitor mysqld processes so that mysqld restarts if the Mysqld_safe process terminates abnormally mysqld
[Root@test4 ~]#/usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql & [1] 20571 [root@test4 ~]# 130617 07:57:29 mysqld_safe to ' Logging T4.wolf.org.err '. 130617 07:57:29 Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/var
[Root@test4 ~]# [root@test4 ~]# PS aux|grep mysql Root 20571 1.0 0.2 106012 1344 pts/0 S 07:57 0:00/ Bin/sh/usr/local/mysql/bin/mysqld_safe--defaults-file=/etc/my.cnf--user=mysql MySQL 20680 1.0 1.3 125308 6652 pts/0 Sl 07:57 0:00/usr/local/mysql/libexec/mysqld--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql--datadi R=/usr/local/mysql/var--user=mysql--log-error=/usr/local/mysql/var/test4.wolf.org.err--pid-file=/usr/local/ Mysql/var/test4.wolf.org.pid--socket=/tmp/mysql.sock--port=3306
Error:
Mysqld_safe Logging to '/usr/local/mysql/data/linux.err '.
Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data
Mysqld_safe mysqld from PID File/usr/local/mysql/data/linux.pid ended
Workaround: Initialize MySQL
[Root@test4 ~]#/usr/local/mysql/bin/mysql_install_db--user=mysql
Second, Mysql.server
Mysql.server is a shell script that calls Mysqld_safe
It's executing files in $mysql_base/share/mysql/mysql.server and Support-files/mysql.server
Mysql.server start reads [Mysql.server] and [mysqld] and reads [Mysql_server] groups for compatibility
[Root@test4 ~]# CP Mysql-5.1.70/support-files/mysql.server/etc/init.d/mysql
[Root@test4 ~]# chmod u+x/etc/init.d/mysqld [root@test4 ~]# service mysqld start starting MySQL success! [Root@test4 ~]# PS aux|grep mysql root 20571 0.0 0.2 106012 1344 pts/0 S 07:57 0:00/bin/sh/usr/local/m Ysql/bin/mysqld_safe--defaults-file=/etc/my.cnf--user=mysql mysql 20680 0.0 1.3 125308 6652 pts/0 Sl 07:57 0:00/usr/local/mysql/libexec/mysqld--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql--datadir=/usr/local/ Mysql/var--user=mysql--log-error=/usr/local/mysql/var/test4.wolf.org.err--pid-file=/usr/local/mysql/var/ Test4.wolf.org.pid--socket=/tmp/mysql.sock--port=3306
Source: http://wolfword.blog.51cto.com/4892126/1241303
See more highlights of this column: http://www.bianceng.cnhttp://www.bianceng.cn/database/MySQL/