Basically, mysql has two major problems. 1. there is no problem starting mysql for the first time. I have done some operations on mysql, especially when I delete some accounts that are not in mysql, I will encounter this problem when I restart mysql # etcinit. dmysqldrestartstoppi basically encounters two major problems when using mysql.
1. there is no problem starting mysql for the first time. after you perform some operations on mysql, especially after deleting some accounts in mysql, you will encounter such problems when you restart mysql.
#/Etc/init. d/mysqld restart
Stopping mysql [OK]
Timeout error occurred trying to start MySQL Daemon. [failure] |
However, mysql has actually started at this time, because the netstat-ln command is used to check that Port 3306 has been started. mysql-u root-p password can also be used to connect to the database.
This is actually a bug in the mysql-3.x (you can look at the bugzilla of mysql and the bugzilla of redhat ).
What causes connection timeout?
Let's take a look at how the/etc/init. d/mysqld startup script works. pay attention to the following section.
|
# If you 've removed anonymous users, this line must be changed
# Use a user that is allowed to ping mysqld.
Ping = "/usr/bin/mysqladmin-uUNKNOWN_MYSQL_USER ping"
# Spin for a maximum of ten seconds waiting for the server to come up
If [$ ret-eq 0]; then
For x in 1 2 3 4 5 6 7 8 9 10; do
If [-n "'$ ping 2>/dev/null"']; then
Break;
Else
Sleep 1;
Fi
Done
If! ([-N "'$ ping 2>/dev/null"']); then
Echo "Timeout error occurred trying to start MySQL
Daemon. "action $" Starting $ prog: "/bin/false
Else
Action $ "Starting $ prog:"/bin/true
Fi
Else
Action $ "Starting $ prog:"/bin/false
Fi
[$ Ret-eq 0] & touch/var/lock/subsys/mysqld
Return $ ret |
We can see that the script determines whether mysql is started and uses the mysqladmin ping command.
To execute this command correctly, you must be able to log on to mysql. now some default accounts have been deleted, and other accounts have set a password (no password is set by default ). so it cannot connect to mysql.
Run the following command to test
# Mysqladmin-u root-ppassword ping
Mysql alive |
When you provide the account and password, the ping command can be correctly executed.
This bug can be solved in mysql's new mysql4.x.
However, RH9 to FC3 has been using mysql3.x (however, mysql officially seems to have launched mysql4.1, FC needs to consider the problem ).
So I used the following method for temporary solution.
A) create an account without a password or any permissions.
B) modify/etc/init. d/mysqld
The following are my specific operations:
|
# Mysql-u root-p passwd
Mysql> GRANT select ON test. *Daemon @ localhost
Mysql> revoke select on test. * fromDaemon @ localhost |
Open/etc/init. d/mysqld
Set the following line
Ping = "/usr/bin/mysqladmin-uUNKNOWN_MYSQL_USER ping"
Change
Ping = "/usr/bin/mysqladmin-udaemon ping"
Save and exit.