linux下如何修改Mysql的root密码
2015-01-04 21:54
435 查看
今天,忘了mysql下的root密码,想重置一下,但找了多个网站上的方法均有问题,最后参考几家的过程,经过不断尝试获得,终于成功了,下面特将过程分享给大家:
环境:
操作系统:Centos 5.5
数据库:MySQL 5.0.77
过程:
1、关闭mysql。
[root@localhost ~]#service mysqld stop
StoppingMySQL: [
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 endwith ; 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 thebuffer.
4、使用mysql数据库。
mysql>use mysql;
Reading table information for completion of table and columnnames
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
StoppingMySQL: [
OK ]
StartingMySQL: [
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
StoppingMySQL: [
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 endwith ; 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 thebuffer.
4、使用mysql数据库。
mysql>use mysql;
Reading table information for completion of table and columnnames
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
StoppingMySQL: [
OK ]
StartingMySQL: [
OK ]
[1]+ Done mysqld_safe --skip-grant-tables --skip-networking
现在你可以使用新的密码登录mysql了。
相关文章推荐
- 在Linux下如何修改Mysql的用户(root)的密码
- Linux下如何修改mysql的root用户密码
- linux下如何修改Mysql的root密码
- 如何在Linux下修改Mysql的用户(root)密码
- linux 中mysql 忘记root密码如何修改
- Linux mysql安装修改root密码服务
- 在Linux系统环境下修改MySQL的root密码
- ZT.如何修改遗失MYSQL的ROOT用户密码
- 如何修改遗失的MySQL的ROOT用户密码
- 忘记mysql密码下如何Windows下和Linux下重置了MYSQL的root的密码
- Linux下MySQL修改root密码
- 如何修改遗失MYSQL的ROOT用户密码
- linux下mysql修改root密码
- 在Linux系统环境下修改MySQL的root密码
- 忘记MySql的root密码如何修改
- Linux下修改mysql的root密码(忘记密码)
- 如何修改mysql的root密码
- Linux系统下修改MySQL的root密码
- Linux下如何找回mysql的root密码