作家
登录

Mysql5.7忘记root密码及mysql5.7修改root密码的方法

作者: 来源: 2017-04-14 09:17:36 阅读 我要评论

【引自豆花饭烧土豆的博客】封闭正在运行的 MySQL :

运行

  1. [root@www.woai.it ~]# mysqld_safe --skip-grant-tables & 

为了安然可以如许禁止长途连接:

  1. [root@www.woai.it ~]# mysqld_safe --skip-grant-tables --skip-networking & 

应用mysql连接server:

  1. [root@www.woai.it ~]# mysql -p 
  1. mysql> update mysql.user set authentication_string=password('123qwe'where user='root' and Host = 'localhost'

而是将加密后的用户暗码存储于authentication_string字段

更改暗码:

  1. mysql> flush privileges
  2.  
  3. mysql> quit; 

修改完毕。重启

  1. [root@localhost ~]# service mysql restart 

然后mysql就可以连接了

但此时操作似乎功能不完全,还要alter user…

  1. mysql> alter user 'root'@'localhost' identified by '123'

如许也可以:

  1. mysql> set password for 'root'@'localhost'=password('123'); 
  1. mysqladmin: [Warning] Using a password on the command line interface can be insecure. 
  2.  
  3. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. 

重点给大年夜家介绍下mysql 5.7 root暗码修改

MySQL治理者暗码设置或修改:

根据官方解释5.6今后版本,第一次启动时会在root目次下临盆一个随机暗码,文件名.mysql_secret。

  1. [root@bright ~]# cat /root/.mysql_secret 
  2.  
  3. Password set for user 'root@localhost' at 2015-03-27 23:12:10 
  4.  
  5. :Jj+FTiqvyrF 
  6.  
  7. [root@bright ~]# cd /usr/local/mysql/bin/ 
  8.  
  9. [root@bright bin]# ./mysqladmin -u root -h localhost 

      推荐阅读

      百万自媒体大V的数据分析师成长线路,薪水过万难吗?

    作者:邓凯“他们须要大年夜数据中找到有效的┞锋相,然后解释给引导者。” – Rchard Snee Emc今天这个标题有点大年夜,内容可能涉及的比较多,但也是数据君多年来一向想>>>详细阅读


    本文标题:Mysql5.7忘记root密码及mysql5.7修改root密码的方法

    地址:http://www.17bianji.com/lsqh/34772.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)