MySQL: Starting MySQL….. ERROR! The server quit without updating PID file解决办法

来源:互联网 发布:朗威数字化实验室 淘宝 编辑:程序博客网 时间:2024/06/05 11:20

1 问题

[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file(/var/lock/subsys/mysql[FAILED]
[root@localhost mysql]#/etc/rc.d/init.d/mysql start
Starting MySQL...The server quit withoutupdating PID file(/usr/local/mysql/data/localhost.localdomain.pid).                             [FAILED]

 

2 原因

没有初始化权限表

 

3 解决办法

#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db

 

4 本人解决过程

[root@localhost ~]# cd/usr/local/mysql

[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$scripts/mysql_install_db
Installing MySQLsystem tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql&
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to'/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databasesfrom /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running(11830)                                      OK  ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
StartingMySQL                                             OK  ]

 

 

附一文:MySQL:Starting MySQL….. ERROR! The server quit without updating PIDfile

FROM:http://icesquare.com/wordpress/mysql-starting-mysql-error-the-server-quit-without-updating-pid-file/

 

MySQL: <wbr>Starting <wbr>MySQL鈥.. <wbr>ERROR! <wbr>The <wbr>server <wbr>quit <wbr>without <wbr>updating <wbr>PID <wbr>file解决办法



This step-by-step guide is mainly for FreeBSD, however the idea isthe same for Linux. Every once a while, when I update my FreeBSDbox, the system likes to shutdown my MySQL server. Therefore, Ineed to start it again after the update is done. Unfortunately, theupgrade process is not smooth every time. Sometimes it will throwme some error.

/usr/local/etc/rc.d/mysql.server start

Oh well, I got the following error messages:

Starting MySQL..... ERROR! The server quit without updating PID file.

Sometimes, the message will tell you the exact location of whichPID file:

Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/www.icesquare.com.pid).

There are several solutions to troubleshoot these problems. Iwill go over each one by one.

Solution 1: Reboot The Computer

Although it sounds simple, but it really works. During thesystem upgrade, the OS may disable some of your daemons. Instead oftroubleshooting each one by one, the easiest way is to starteverything over. For example, I experienced this problem todayafter upgrading the Apache and Ruby (Yes, MySQL isnot part of the update), and I got this error message afterward.After rebooting the computer, the error message is gone.

Solution 2: Remove Your MySQL Config File

If you have modified your MySQL configuration file, MySQL maynot like it few versions after (MySQL is not backward compatibilityfriendly). It can be the problem of using an unsupported variable,or something similar. The easiest way is to remove yourconfiguration file, and try to start the MySQL server again:

Backup your MySQL configuration first.

mv /etc/my.cnf /etc/my.cnf.backup

And restart the MySQL server again:

/usr/local/share/mysql/mysql.server start

Hopefully you will see the following message:

Starting MySQL. SUCCESS!

Solution 3: Upgrade Your Database File

Sometimes, the newer MySQL doesn’t like the database created inearlier version. I discovered this when I upgrade to MySQL5.5.7:

Starting MySQL..... ERROR! The server quit without updating PID file (/var/db/mysql/www.icesquare.com.pid).

Since MySQL tells me which PID file causes the problem, I openthe file and take a look what’s going on:

sudo tail /var/db/mysql/www.icesquare.com.err

And I saw something interesting: tables: Table‘mysql.proxies_priv’ doesn’t exist:

101112 10:49:16  InnoDB: Initializing buffer pool, size = 128.0M101112 10:49:16  InnoDB: Completed initialization of buffer pool101112 10:49:16  InnoDB: highest supported file format is Barracuda.101112 10:49:17  InnoDB: 1.1.3 started; log sequence number 1589404101112 10:49:17 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.proxies_priv' doesn't exist101112 10:49:17 mysqld_safe mysqld from pid file /var/db/mysql/www.icesquare.com.pid ended
 

The reason is very simple. MySQL could not open a table createdin the earlier version (< 5.7.7) because it is notcompatible with the current version. So, we can try to start theMySQL in safe mode through rc.d. First, you can edit the/etc/rc.conf and put the following into thefile:

mysql_enable="YES"mysql_args="--skip-grant-tables --skip-networking"

Restart MySQL through rc.d:

/usr/local/etc/rc.d/mysql-server start

If you did it right, you should see something like thefollowing:

Starting MySQL.. SUCCESS!

Now, MySQL is already running the safe-mode. We want to performa MySQL upgrade on all tables:

sudo mysql_upgrade

You should see something like this:

Looking for 'mysql' as: mysqlLooking for 'mysqlcheck' as: mysqlcheckRunning 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'Running 'mysqlcheck' with connection arguments: '--port=3306' '--socket=/tmp/mysql.sock'mysql.columns_priv                                 OKmysql.db                                           OKmysql.event                                        OKmysql.func                                         OKmysql.general_log                                  OKmysql.help_category                                OKmysql.help_keyword                                 OKmysql.help_relation                                OKmysql.help_topic                                   OKmysql.host                                         OKmysql.ndb_binlog_index                             OKmysql.plugin                                       OKmysql.proc                                         OKmysql.procs_priv                                   OKmysql.servers                                      OKmysql.slow_log                                     OKmysql.tables_priv                                  OKmysql.time_zone                                    OKmysql.time_zone_leap_second                        OKmysql.time_zone_name                               OKmysql.time_zone_transition                         OKmysql.time_zone_transition_type                    OKmysql.user                                         OKRunning 'mysql_fix_privilege_tables'...OK

Now, we want to switch the MySQL back to normal mode bycommenting the extra options in /etc/rc.conf:

mysql_enable="YES"#mysql_args="--skip-grant-tables --skip-networking"

And restart MySQL through /etc/rc.d:

/usr/local/etc/rc.d/mysql-server restart

Now the MySQL is up and running again!

Happy MySQLing.

–Derrick