mysql账号密码相关

mysql> flush privileges;

 


法二:

(适合密码丢失后通过–skip-grant-tables 参数启动数据库后修改密码)

mysql> desc mysql.user;
+————————+———————————–+——+—–+———+——-+
| Field | Type | Null | Key | Default | Extra |
+————————+———————————–+——+—–+———+——-+
| Host | char(60) | NO | PRI | | |
| User | char(16) | NO | PRI | | |
| Password | char(41) | NO | | |

 

mysql> select user,host,password from mysql.user;
+——+—————+——————————————-+
| user | host | password |
+——+—————+——————————————-+
| root | % | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
| root | 51 | |
| root | 127.0.0.1 | |
| root | ::1 | |
| | localhost | |
| | 51 | |
| root | 192.168.42.52 | *FD571203974BA9AFE270FE62151AE967ECA5E0AA |
+——+—————+——————————————-+
7 rows in set (0.00 sec)

 

->update mysql.user set password=password(‘111111′) where user=’root’ and host=’%’;

->flush privileges;

 

法三:

->set password=password(‘111111’);


 

 

密码丢失找回:

停掉先

[root@localhost ~]# /etc/init.d/mysqld stop
Shutting down MySQL. [ OK ]

忽略授权表启动:

[root@52 ~]# /application/mysql/bin/mysqld_safe –skip-grant-tables -user=mysql &

[root@52 ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.

 

>update mysql.user set password=password(‘111111′) where user=’root’ and host=’localhost’;

>flush privileges;

 

重启

[root@52 ~]# mysqladmin -uroot -p111111 shutdown

[root@52 ~]# /etc/init.d/mysqld start
Starting MySQL.. [ OK ]

完成,登陆。

 

 

Author: YJZ

发表评论

电子邮件地址不会被公开。