zoukankan      html  css  js  c++  java
  • 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;
    +--------------------+
    | Database |
    +--------------------+
    | information_schema |
    | test |
    +--------------------+
    只显示这个两个数据库,看不到mysql数据库
    解决方法:
    此问题实际上是用户没有权限:
    1. 关闭mysql,service mysqld stop/service mysql 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','','' ,'','', 0,0,0 , 0 );
    如果已经存在了host为localhost的记录,则先删除该记录,delete from user where host='localhost';
    然后再进行上面的insert操作,注意的是mysql版本的不同,user表的结构会略有差异,比如上面的语句我执行的时候就在最后加了三个参数,0,'','',具体根据实际情况而定
    操作完成后,将两个ssh连接都关闭,然后再重新连接一个ssh,启动mysql,service mysqld start,然后用mysql命令连接mysql数据库
    [root@localhost ~]#mysql -uroot -p
    密码为空。
    [如果此时还连接不上,再重启一下mysql就好了,service mysqld restart]。
    然后就可以用 [root@localhost ~]#mysqladmin -uroot -p password 'newpassword' 来设置密码了。
    或者用 use mysql
    update user set password=‘’ where user='root' 来修改密码

  • 相关阅读:
    【转载】如何学JavaScript?前辈的经验之谈
    javascript基础学习心得01
    CSS之浮动
    HTML5基础学习心得
    如何使用HTML5的canvas属性
    HTML标记语言
    HTML+CSS学习
    线性表
    (2)协程之 greenlet模块
    (1)协程之理论
  • 原文地址:https://www.cnblogs.com/wxjnew/p/6472289.html
Copyright © 2011-2022 走看看