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
Step # 6: 验证
/etc/init.d/mysql start mysql -u root -p
输入这条命令按enter键后再输入密码,就能进去数据库啦!
reference:
https://www.cyberciti.biz/tips/recover-mysql-root-password.html
看完以上关于Mysql密码重置方法,很多读者朋友肯定多少有一定的了解,如需获取更多的行业知识信息 ,可以持续关注我们的行业资讯栏目的。