linux mysql 忘记root密码
2015-03-04 11:18
501 查看
今天,忘了mysql下的root密码,想重置一下,但找了多个网站上的方法均有问题,最后参考几家的过程,经过不断尝试获得,终于成功了,下面特将过程分享给大家:
环境:
操作系统:Centos 5.5
数据库:MySQL 5.0.77
过程:
1、关闭mysql。
[root@localhost ~]#service mysqld stop
Stopping MySQL: [ OK ]
2、跳过授权表启动mysql,关闭网络监听,让其后台运行或者开个新终端。
[root@localhost ~]#mysqld_safe --skip-grant-tables --skip-networking
Starting mysqld daemon with databases from /var/lib/mysql
提示:此时按下CTRL-Z
[1]+ Stopped mysqld_safe --skip-grant-tables --skip-networking
[root@localhost ~]#bg
[1]+ mysqld_safe --skip-grant-tables --skip-networking &
3、链接mysql服务器。
[root@localhost ~]#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
4、使用mysql数据库。
mysql>use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
5、设置root新密码。
mysql>update user set password=password('123') where user='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
6、退出mysql。
mysql>quit
bye
7、重起mysql。
[root@localhost ~]#service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
120928 11:38:28 mysqld ended
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables --skip-networking
现在你可以使用新的密码登录mysql了。
环境:
操作系统:Centos 5.5
数据库:MySQL 5.0.77
过程:
1、关闭mysql。
[root@localhost ~]#service mysqld stop
Stopping MySQL: [ OK ]
2、跳过授权表启动mysql,关闭网络监听,让其后台运行或者开个新终端。
[root@localhost ~]#mysqld_safe --skip-grant-tables --skip-networking
Starting mysqld daemon with databases from /var/lib/mysql
提示:此时按下CTRL-Z
[1]+ Stopped mysqld_safe --skip-grant-tables --skip-networking
[root@localhost ~]#bg
[1]+ mysqld_safe --skip-grant-tables --skip-networking &
3、链接mysql服务器。
[root@localhost ~]#mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.0.77 Source distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
4、使用mysql数据库。
mysql>use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
5、设置root新密码。
mysql>update user set password=password('123') where user='root';
Query OK, 3 rows affected (0.01 sec)
Rows matched: 3 Changed: 3 Warnings: 0
6、退出mysql。
mysql>quit
bye
7、重起mysql。
[root@localhost ~]#service mysqld restart
STOPPING server from pid file /var/run/mysqld/mysqld.pid
120928 11:38:28 mysqld ended
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]
[1]+ Done mysqld_safe --skip-grant-tables --skip-networking
现在你可以使用新的密码登录mysql了。
相关文章推荐
- linux下 mysql 的root用户忘记密码解决方案
- Linux下修改mysql的root密码(忘记密码)
- 忘记mysql密码下如何Windows下和Linux下重置了MYSQL的root的密码
- Linux平台 mysql的root密码忘记解决办法
- mysql 忘记root密码(linux ok, windows 没试)
- linux下启动Mysql忘记root密码的解决办法
- linux下mysql的root密码忘记解决方
- 简化mysql –uroot –p登录 linux忘记mysql密码处理方法 解决root没有权限
- linux下mysql的root密码忘记怎么办
- linux下mysql的root密码忘记解决方法
- linux下mysql的root密码忘记解决方法
- linux下mysql的root密码忘记解决方
- linux下mysql忘记root密码的解决方法
- linux下mysql忘记root密码的解决方法
- linux忘记mysql的root用户密码
- linux下 mysql 忘记root用户密码解决办法
- 在Linux环境下mysql的root密码忘记解决方法
- LINUX平台下忘记mysql的root密码解决办法
- linux下mysql的root密码忘记解决方案
- Linux平台:忘记mysql的root密码解决办法