问题现象:
启动mysql的时候报如下错误:
Starting MySQL.The server quit without updating PID file (datamysqllinux.pid).
分析过程:
查看启动日志:
InnoDB: 127 rollback segment(s) active.
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
130827 10:46:47 InnoDB: Waiting for the background threads to start
130827 10:46:48 InnoDB: 5.5.32 started; log sequence number 0
130827 10:46:48 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
130827 10:46:48 [Note] - '0.0.0.0' resolves to '0.0.0.0';
130827 10:46:48 [Note] Server socket created on IP: '0.0.0.0'.
130827 10:46:48 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
130827 10:46:48 mysqld_safe mysqld from pid file /data/mysql/linux.pid ended
从日志可以看出系统表没有创建,但mysql_install_db这个脚本是运行过的;
运行时的界面如下:
linux:/usr/bin # perl mysql_install_db
Installing all prepared tables
130827 10:51:13 /usr/sbin/mysqld: Shutdown Complete
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h linux.site password 'new-password'
See the manual for more instructions.
NOTE: If you are upgrading from a MySQL <= 3.22.10 you should run
the /usr/bin/mysql_fix_privilege_tables. Otherwise you will not be
able to use the new GRANT command!
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at https://order.mysql.com
但是执行过mysql_install_db后,数据目录下仍旧为空;系统表未创建成功;
问题原因和解决方法:
mysql_install_db没加特定参数,系统表没有创建成功;
重新加参数执行mysql_install_db之后可以成功创建系统表,mysql启动成功;
mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/