admin管理员组文章数量:1638924
背景:centos新安装的mysql数据库。使用DbEaver连接mysql库时,发现左边不显示表。使用命令框mysql -uroot回车登录时,发现只能看到information_schema一个数据库了。
原因:
因为mysql数据库的user表里,存在用户名为空的账户即匿名账户,导致登录的时候是虽然用的是root,但实际是匿名登录的,通过错误提示里的''@'localhost'可以看出来
解决:
1.关闭mysql
service mysql stop 或 systemctl stop mysql 或 systemctl stop mysqld
2.屏蔽权限:如下图所示
直接输入命令: mysqld_safe --skip-grant-table
屏幕出现: mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
3.新开起一个终端操作
登录:mysql -u root mysql;
show databases;
use mysql;
查看:select host,user,password from user where user='root';
修改密码:update user set Password=password('root') where User='root';//我设置的密码是root;
删除空账号: delete from user where USER='';
mysql> FLUSH PRIVILEGES; //记得要这句话,否则如果关闭先前的终端,又会出现原来的错误
mysql>quit
这时候就能正常连接并显示了。
本文标签: 数据库mysqlinformationschema
版权声明:本文标题:MySQL只有information_schema一个数据库 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1729277777a1193718.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论