码迷,mamicode.com
首页 > 数据库 > 详细

MySql 5.7 重置root密码

时间:2019-05-13 19:05:10      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:ash   table   ssi   network   shutdown   .so   director   miss   roo   

一、以安全模式登录

# Stop MySQL
sudo service mysql stop

# Make MySQL service directory.
sudo mkdir -p /var/run/mysqld

# Give MySQL user permission to write to the service directory.
sudo chown mysql:mysql /var/run/mysqld

# Start MySQL manually, without permission checks or networking.
sudo mysqld_safe --skip-grant-tables &

# Log in without a password.
mysql -u root

二、修改密码

UPDATE mysql.user SET authentication_string=PASSWORD('NEW-PASSWORD'), plugin='mysql_native_password' WHERE User='root' ;
EXIT;

三、重启数据库

# Turn off MySQL.
sudo mysqladmin -S /var/run/mysqld/mysqld.sock shutdown

# Start the MySQL service normally.
sudo service mysql start

MySql 5.7 重置root密码

标签:ash   table   ssi   network   shutdown   .so   director   miss   roo   

原文地址:https://www.cnblogs.com/kelsen/p/10858351.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!