mysql忘记密码修改
2017-05-12 21:51
363 查看
偶尔会忘记mysql密码,特别是在测试环境中,此时该怎么办呢?
mysql忘记密码修改
1、关闭mysql
2、启动mysql时跳过mysql的用户验证
3、另开一个终端,登录mysql(不要指定用户密码,因为此时没有开启mysql用户验证)
此时,看不到密码原文,只看到密码md5加密后的密文。
4、mysql命令行中重新修改密码
5、杀掉mysqld进程
6、重启mysql服务,并使用新设置密码登录
ok,密码已修改成功,并可正常使用。
mysql忘记密码修改
1、关闭mysql
[root@vm01 ~]# service mysqld stop Stopping mysqld: [ OK ]
2、启动mysql时跳过mysql的用户验证
[root@vm01 ~]# /usr/libexec/mysqld --skip-grant-tables 170512 21:27:16 InnoDB: Initializing buffer pool, size = 8.0M 170512 21:27:16 InnoDB: Completed initialization of buffer pool 170512 21:27:17 InnoDB: Started; log sequence number 0 900270 170512 21:27:17 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution
3、另开一个终端,登录mysql(不要指定用户密码,因为此时没有开启mysql用户验证)
[root@vm01 src]# mysql -h127.0.0.1 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 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 mysql> select host,user,password from user; +-------------------------+------+-------------------------------------------+ | host | user | password | +-------------------------+------+-------------------------------------------+ | localhost | root | *DBB5837ZB74329105ER4568DDA7DC67ED2CA2ABC | | tongyeyun01.localdomain | root | *DBB5837ZB74329105ER4568DDA7DC67ED2CA2ABC | | 127.0.0.1 | root | *DBB5837ZB74329105ER4568DDA7DC67ED2CA2ABC | +-------------------------+------+-------------------------------------------+ 3 rows in set (0.00 sec)
此时,看不到密码原文,只看到密码md5加密后的密文。
4、mysql命令行中重新修改密码
# password函数中字符串为你需要设置的密码 mysql> update user set password=password("123456"); Query OK, 0 rows affected (0.00 sec) Rows matched: 3 Changed: 0 Warnings: 0
5、杀掉mysqld进程
[root@vm01 ~]# kill -9 `ps -ef|grep mysqld|grep -v grep|awk '{print $2}'` [root@vm01 ~]# ps -ef|grep mysqld root 14971 14500 0 21:49 pts/3 00:00:00 grep mysqld
6、重启mysql服务,并使用新设置密码登录
[root@vm01 ~]# service mysqld start Starting mysqld: [ OK ] [root@vm01 ~]# mysql -h127.0.0.1 -uroot -p123456 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | cmdb_v2 | | monitor | | mysql | | ops | | test | | test_ops | +--------------------+ 7 rows in set (0.00 sec) mysql>
ok,密码已修改成功,并可正常使用。
相关文章推荐
- Mac下修改mysql初始密码和Windows忘记密码的处理
- Windows10下MySQL5.7.19安装教程 MySQL忘记root密码修改方法
- MySQL忘记root用户密码修改方法
- mysql 5.7.16 忘记root 密码 如何修改root密码
- Mysql的Root密码忘记,查看或修改的解决方法(图文介绍)
- mysql修改密码及忘记密码如何处理
- MySQL忘记密码和修改密码案例
- MySql修改密码&忘记密码后重设密码(Linux)
- Mysql忘记密码但是保存以前连接数据库连接的修改密码方法
- 忘记mysql的登录密码如何修改
- mysql忘记密码,root用户密码修改
- mysql修改root密码及root密码忘记的解决办法
- Mysql 忘记root密码后修改root密码
- Linux环境下修改mysql用户密码(忘记密码)
- Linux/Mac MySQL忘记密码命令行修改密码的方法
- mysql建用户和修改密码和忘记密码的解决办法
- MySQL忘记密码或者因为修改mysql.user导致无法登陆解决方法
- mysql忘记密码修改
- mysql5.7忘记root密码的修改方法
- mysql学习之-密码管理(默认密码,修改密码,解决忘记密码)