安装完mysql5.7后忘记了暗码,须要重置root暗码;
第一步:修正配置文件免暗码登录mysql
vim /etc/my.cnf ##在my.cnf的[mysqld]字段到场 skip-grant-tables ## 重启mysql效劳 service mysqld restart
第二步:免暗码登录mysql
mysql -u root ##password直接回车
第三步: 给root重置暗码为空
mysql>use mysql; ## mysql 5.7.9今后烧毁了password字段,字段名修正为authentication_string mysql>update user set authentication_string='' where user='root'; ## 革新数据库 mysql>flush privileges;
第四步: root重置暗码
退出mysql,删除/etc/my.cnf文件末了的 skip-grant-tables 重启mysql效劳,运用root用户举行登录,由于上面设置了authentication_string为空,所以能够免暗码登录。
alter user 'root'@'localhost' identified by '#新暗码#';
功德圆满,修正胜利
以上就是mysql5.7重置root暗码的步骤详解的细致内容,更多请关注ki4网别的相干文章!