mysql 执行show databases没有mysql库
在网上查了一下相关的案例,发现与权限表mysql.user表有关
解决方法:
关闭数据库
service mysqld stop
以跳过权限认证方式启动mysql
mysqld_safe --defaults-file=/etc/my.cnf --skip-grant-tables &
删除mysql.user表中host名为'localhost'的记录
mysql> use mysql
mysql> delete from user where host='localhost';
Query OK, 7 rows affected (0.00 sec)
mysql> INSERT INTO `user` VALUES ('localhost','root','','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y', 'Y', '','','','',0,0,0,0);
Query OK, 1 row affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
再次重启数据库后,正常
service mysqld restart
mysqld_safe --defaults-file=/etc/my.cnf &
更改root密码
mysqladmin -u root -proot password