linux的mysql下看不到mysql数据库…
2014-03-08 10:08
204 查看
[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', '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', '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' 来设置密码了。
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', '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', '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' 来设置密码了。
相关文章推荐
- linux的mysql下看不到mysql数据库解决方案
- linux的mysql下看不到mysql数据库解决方案
- linux的mysql权限错误导致看不到mysql数据库
- linux的mysql权限错误导致看不到mysql数据库
- Linux下用源码安装 MySQL 初始化mysql数据库时提示字符编码错误的解决办法
- Mysql学习总结(44)——Linux下如何实现mysql数据库每天自动备份定时备份
- MySQL字符集设置—MySQL数据库乱码问题 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http://www.linuxidc.com/Linux/2011-01/31531.htm
- mysql show databases 看不到mysql数据库
- 【MySql】在Linux下安装MySql数据库
- linux下mysql数据库编程mysql_real_connect()出现segment fault
- Linux下的mysql用户管理,常用sql语句,mysql数据库备份恢复
- linux mysql 更改MySQL数据库目录位置
- (Mysql 二)Linux C语言显示mysql数据库中某个表的数据
- 【MySQL】Linux下导入导出MySQl数据库的命令
- linux mysql 更改MySQL数据库存储路径(datadir)
- linux学习第五十篇:MySQL创建用户以及授权,常用sql语句,MySQL数据库备份恢复
- bug宝典之linux root用户看不到mysql数据库了
- Linux中Mysql root用户看不到mysql库问题解决方式
- Linux下安装MySQL数据库mysql-5.7.11
- linux备份mysql数据库与恢复mysql备份数据