zoukankan      html  css  js  c++  java
  • MySQL安装完成后重置密码

    1.安装完成后,登陆出错,这时候需要修改/etc/my.cnf中的配置文件,跳过密码验证,进入MySQL。在配置文件中任意行输入skip-grant-tables

    2.然后重启服务;

    3.登陆mysql 

      ~]# mysql

      或者~]# mysql -uroot  -p

    4.登陆进去之后进去开始修改密码:

      mysql> use mysql

      mysql> update user set password=password('Root@123456') where user='root'

        -> ;

        ERROR 1054 (42S22): Unknown column 'password' in 'field list'   ==>出错了,mysql5.7里面mysql数据库下已经没有password这个字段了,password字段改成了authentication_string

    5.重新输入语句修改密码:

      

     mysql> use mysql

      mysql> update user set password=password('Root@123456') where user='root'          ==>或者(ALTER USER 'root'@'localhost' IDENTIFIED  BY 'Root@123456')

        -> ;

     

      Query OK, 1 row affected, 1 warning (0.02 sec)
      Rows matched: 1 Changed: 1 Warnings: 1

    6.退出MySQL,将配置文件里的skip-grant-tables删除掉。

      mysql> quit

      Bye

     删除配置文件里的ship-grant-tables,再重新启动服务: 

      [root@localhost etc]# vi /etc/my.cnf
      [root@localhost etc]# systemctl restart mysqld
      [root@localhost etc]# systemctl status mysqld

    7.重新登陆MySQL,需要密码登陆才能成功。

    或者MySQL刚完成安装时都有临时密码,我们可以先获取临时密码,登陆进去之后,在进行之前上面的操作,完成密码修改。

      ~]#  grep 'temporary password' /var/log/mysqld.log

      

  • 相关阅读:
    android学习---ListView
    android学习---ViewStub惰性装载控件
    android学习---TabHost
    微信小程序二维码带参数
    as
    niginx高性能原因
    Nginx动态反向代理1
    Niginx反向代理负载均衡
    jmeter测试,定制化内嵌tomcat调优
    Git通过密钥对远程仓库上传和更新详细操作
  • 原文地址:https://www.cnblogs.com/trrip/p/9109706.html
Copyright © 2011-2022 走看看