MySQL无法启动:Table mysql.host doesn t exist
MySQL无法启动:Table \'mysql.host\' doesn\'t exist,下面我来介绍如何解决这个问题。安装很顺利但无法启动,想了想可能是之前误操作/var/目录的权限,导致没有写权限导致的。但重新设置写权限之后仍不能正确启动。
提示:
Timeout error occurred trying to start MySQL Daemon.
Starting MySQL: [FAILED]
检查了MySQL的日志(cat /var/log/mysqld.log)发现提示一个错误([ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist),如图:
猜测可能是MySQL的默认数据库没正常安装,但卸载MySQL(yum remove mysql-server)再重装(yum install mysql-server)还是不行,现象和原来一样。后来找到一个专门安装默认数据库的命令:mysql_install_db,执行之后,再启动MySQL(/etc/init.d/mysqld start)终于看到久违的OK:
代码如下 | 复制代码 |
# /etc/init.d/mysqld start |
问题二
用safe_mysqldq启动的时候,出现
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
最终解决方法如下:
在mysql的安装目录下,我的是/usr/local/mysql
代码如下 | 复制代码 |
./scripts/mysql_install_db --usrer=mysql --datadir=/usr/local/mysql/data/ |
原因是重装的时候数据目录不一致导致
问题三
说一下我解决的过程:
按照mysql的安装步骤:
代码如下 | 复制代码 |
shell> groupadd mysql shell> useradd -g mysql mysql shell> gunzip shell> cd mysql-VERSION shell> ./configure --prefix=/usr/local/mysql shell> make shell> make install shell> scripts/mysql_install_db --user=mysql shell> chown -R root /usr/local/mysql shell> chown -R mysql /usr/local/mysql/var shell> chgrp -R mysql /usr/local/mysql shell> cp support-files/my-medium.cnf /etc/my.cnf shell> /usr/local/mysql/bin/mysqld_safe --user=mysql & |
这样标准进行下来是没有问题的,但在最后一步启动mysql的时候我希望将数据库的数据文件放在另外一个目录下面,启动命令修改为:
代码如下 | 复制代码 |
shell>/usr/local/mysql/bin/mysqld_safe --user=mysql --log-error=/u01/mysql/mysql_error/error --datadir=/u01/mysql/data |
这个时候就出现问题了, 因为在进行初始化数据库权限表的那一步的时候默认创建的权限表在默认目录/usr/local/mysql/var下面,这就造成了,上面的错误无法找到 权限表:Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
解决办法 在运行初始化权限表的时候使用增加参数--datadir ,命令格式为:
代码如下 | 复制代码 |
shell> scripts/mysql_install_db --user=mysql --datadir=/u01/mysql/data |
推荐阅读
-
MySQL无法启动:Table mysql.host doesn t exist
-
linux上的mysql报Table 'xxx' doesn't exist的错误解决方法_MySQL
-
MySql报错Table mysql.plugin doesn’t exist的解决方法
-
ERROR 1146 (42S02): Table 'mysql.slow_log' doesn't exist
-
table-mysql 错误:1146 ,Table "XXX" doesn;t exist
-
Linux下MySQL报Table 'xxx' doesn't exist错误解决方法
-
Linux下MySQL报Table 'xxx' doesn't exist错误解决方法
-
ERROR 1146 (42S02): Table 'mysql.slow_log' doesn't exist
-
windows 7启动MySql报错Table 'mysql.plugin' doesn't exist_MySQL
-
windows 7启动MySql报错Table 'mysql.plugin' doesn't exist_MySQL