温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Mysql密码重置方法介绍

发布时间:2020-05-19 14:01:45 来源:网络 阅读:210 作者:三月 栏目:MySQL数据库

本文主要给大家介绍Mysql密码重置方法,文章内容都是笔者用心摘选和编辑的,具有一定的针对性,对大家的参考意义还是比较大的,下面跟笔者一起了解下Mysql密码重置方法吧。 

  • Step # 1: Stop the MySQL server process.
  • Step # 2: Start the MySQL (mysqld) server/daemon process with the –skip-grant-tables option so that it will not prompt for password.
  • Step # 3: Connect to mysql server as the root user.
  • Step # 4: Setup new mysql root account password i.e. reset mysql password.
  • Step # 5: Exit and restart the MySQL server.

ok,五步,开始!

Step # 1 : 停止sql服务

/etc/init.d/mysql stop

输出 Stopping MySQL database server: mysqld.

Step # 2: 启动mysql服务镜像

mysqld_safe --skip-grant-tables &

输出
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe

Step # 3: 以mysql服务的方式去链接数据库

mysql -u root

输出显示
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.1.15-Debian_1-log
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>

Step # 4: 为root用户设置新的密码

mysql> use mysql;
mysql> update user set password=PASSWORD("你的密码") where User='root';
mysql> flush privileges;
mysql> quit

Step # 5: 启动mysql服务

/etc/init.d/mysql stop

Stopping MySQL database server: mysqld
STOPPING server from pid file /var/run/mysqld/mysqld.pid
mysqld_safe[6186]: ended
[1]+  Done                    mysqld_safe --skip-grant-tables</pre>

Step # 6: 验证

 /etc/init.d/mysql start
 mysql -u root -p

输入这条命令按enter键后再输入密码,就能进去数据库啦!

reference:
https://www.cyberciti.biz/tips/recover-mysql-root-password.html

看完以上关于Mysql密码重置方法,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI