MYSQL中没有mysql库

http://blog.csdn.net/liuyifeng1920/article/details/49818851mysql

今天在安装mysql数据库后,想开启远程链接,发现查询不到了mysql数据库自带的mysql数据库,是因为用户的权限问题致使,解决办法以下:
[root@localhost ~]# mysql -uroot -p123

  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection id is 7

  Server version: 5.0.77 Source distribution

  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  mysql>show databases;

  +--------------------+

  | Database |

  +--------------------+

  | information_schema |

  | test |

  +--------------------+

  只显示这个两个数据库,看不到mysql数据库

  解决方法:

  此问题其实是用户没有权限:

  1. 关闭mysql,service mysqld stop

  2. 启动mysql: mysqld_safe --skip-grant-tables

  3. 再打开一个ssh链接服务器,进行mysql操做

  [root@localhost ~]#mysql

  Welcome to the MySQL monitor. Commands end with ; or \g.

  Your MySQL connection id is 7

  Server version: 5.0.77 Source distribution

  Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

  mysql>show databases;

  在这个模式下是能够看到mysql数据库的。

  在数据库名mysql下的user表中,修改相应权限,好比:

  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','','','','',0,0,0,0);

  若是已经存在了host为localhost的记录,则先删除该记录,delete from user where host='localhost';

  而后再进行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','','','','',0,0,0,0);

  操做。

  操做完成后,将两个ssh链接都关闭,而后再从新链接一个ssh,启动mysql,service mysqld start,而后用mysql命令链接mysql数据库

  [root@localhost ~]#mysql -uroot -p

  密码为空。

  [若是此时还链接不上,再重启一下mysql就行了,service mysqld restart]。

  而后就能够用 [root@localhost ~]#mysqladmin -uroot password 'newpassword' 来设置密码了。
相关文章
相关标签/搜索