A workaround that MySQL cannot start under Linux
2010-02-23 15:34:36| Category: UNIX | font size
When I first started to learn MySQL, I brought it with Redhat. What's the start/rc.d/init.d/start
This is simple, but later, the more you learn, the system comes with MySQL, some versions are too low, some with the Web services you want to install the low version of MySQL
Later I learned to install MySQL in tar, my MySQL installed in the/usr/local/mysql directory
Have encountered many problems. The most common are:
ERROR 2002:can ' t connect to local MySQL server through socket
'/tmp/mysql.sock ' (111)
Workaround:
[Email protected] mysql]#/usr/local/mysql/bin/mysqladmin-u root/>-s/var/lib/mysql/mysql.sock password ' your.pas SWD ' or make a connection
Ln-s/var/lib/mysql/mysql.sock/tmp
In fact, the hint can not find/tmp/mysql.sock sometimes not the/tmp directory does not have this file, is the start command wrong, I have encountered
Common several startup ways, oneself also not remember very clearly, if you determine TMP under has mysql.sock this file may try another several commands/usr/local/mysql/bin/mysql-u root-p/usr/local/mysql/bin /mysqld--user=mysql&/usr/local/mysql/bin/mysqld--user=root&/usr/local/mysql/bin/mysqld_safe--user=root &/usr/local/mysql/bin/mysqld_safe--user=mysql&
/usr/local/mysql/bin/safe_mysqld--uer=root& (note that safe_mysqld and Mysqld_safe are different,& that MySQL runs in the background) I'll get an error. Stopping server from PID file
/usr/local/mysql/data/localhost.localdomain.pid 060304 11:46:21 Mysqld Ended
This is a permissions issue, my MySQL directory belongs to the root user, also belongs to the root group, switch to Mysqld_safe boot is no problem, everyone just pay attention to these several mysql,safe_mysqld,mysqld_safe,mysqld, Mysqladmin. Try a few more times
In fact, sometimes MySQL has started normally, check whether MySQL starts command Ps-aux | grep mysqld will see something like this
MySQL 6394 0.0 1.5 10528 992 PTS/3 S 16:16 0:00/usr/local/mysql/
Fresh graduates Job Search Tibaoding Open your career journey resume writing written test real question interview Guide Professional skills Guide Civil service Area
MySQL 6395 0.0 1.5 10528 992 PTS/3 S 16:16 0:00/usr/local/mysql/
MySQL 6396 0.0 1.5 10528 992 PTS/3 S 16:16 0:00/usr/local/mysql/
Root 6422 0.0 1.1 2408 732 PTS/3 S 16:20 0:00 grep mysql
Check if MySQL is listening on port command NETSTAT-TL | grep MySQL netstat-ant will see something like the following TCP 0 0 *:mysql *:* LISTEN
Start MySQL Error:
ERROR 2002 (HY000): Can ' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock ' (2)
1. Check the/ETC/RC.D/INIT.D/MYSQLD status first to see if M y S Q L has been started. Also see if it is a permission issue.
2. Determine if your mysql.sock is in that position,
Mysql-u your MySQL user name-p-s/var/lib/mysql/mysql.sock 3, try: Service mysqld start
4, if it is a permission issue, change the permissions first #chown-R mysql:mysql/var/lib/mysql [[email protected] ~]#/etc/init.d/mysqld start mysql: [OK]
[Email protected] ~]# mysql-uroot-p
ERROR 2002 (HY000): Can ' t connect to local server through socket '/var/lib/mysql/mysql.sock ' (2)
The reason for this is that the/var/lib/mysql access rights issue.
Shell> Chown-r Mysql:mysql/var/lib/mysql
then start server
shell> /etc/init.d/mysql start
Server check /var/after normal startup lib/mysql automatically generates mysql.sock files. But my problem is still not being solved. Problem finally solved:
Method: modify/etc/my.conf: [mysqld]
datadir=/usr/local/mysql/data socket=/var/lib/mysql/mysql.sock [mysql.server] user=mysql
basedir=/usr/local/mysql
If there is not currently a section called [client], add one at the bottom of the file and copy the socket= line under the [mysqld] section such as: [client]
socket=/ var/lib/mysql/mysql.sock
found still, run/etc/init.d/mysql start error:  STARTING MYSQLCOULDN ' t find mysql manager or server
is mysqld service, running/usr/local/mysql/bin/ mysqld_safe &
Problem Solution