Mysql登录后看不到数据库

进入数据库后,只能看到information_schema/test这两个库,其他的数据库都看不到,这是权限出了问题。

关闭Mysql

/usr/local/mysql/support-files/mysql.server stop
#或者
service mysqld stop

用安全模式启动Mysql,如果是自己通过tar包手动安装的Mysql,mysqld_safe命令在“${mysql}/bin”下

mysqld_safe --skip-grant-tables

执行这条命令后,当前ssh命令行会停住,如下图

Mysql登录后看不到数据库

再打开一个ssh连接,登录到mysql数据库

mysql

修改mysql.user表

use mysql;
delete from `user`;
INSERT INTO `user` (`Host`, `User`, `Password`, `Select_priv`, `Insert_priv`, `Update_priv`, `Delete_priv`, `Create_priv`, `Drop_priv`, `Reload_priv`, `Shutdown_priv`, `Process_priv`, `File_priv`, `Grant_priv`, `References_priv`, `Index_priv`, `Alter_priv`, `Show_db_priv`, `Super_priv`, `Create_tmp_table_priv`, `Lock_tables_priv`, `Execute_priv`, `Repl_slave_priv`, `Repl_client_priv`, `Create_view_priv`, `Show_view_priv`, `Create_routine_priv`, `Alter_routine_priv`, `Create_user_priv`, `Event_priv`, `Trigger_priv`, `Create_tablespace_priv`, `ssl_type`, `ssl_cipher`, `x509_issuer`, `x509_subject`, `max_questions`, `max_updates`, `max_connections`, `max_user_connections`, `plugin`, `authentication_string`) VALUES
('%','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','Y','','','','',0,0,0,0,'',''),
('127.0.0.1','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','Y','','','','',0,0,0,0,'',''), ('::1','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','Y','','','','',0,0,0,0,'',''), ('localhost','','','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','Y','','','','',0,0,0,0,'','');

停止mysql

service mysqld stop

或者

${mysql}/support-files/mysql.server stop

以正常模式重新启动

service mysqld start

或者

${mysql}/support-files/mysql.server start

启动后登录mysql数据库,可以正常看到所有的数据库了。

上一篇:Selenium(Python) ddt读取Excel文件数据驱动


下一篇:如何快速掌握DDT数据驱动测试?