网络营销电子商务研究中心  
How to buy the best prescription safety glasses in Canada? Let's study!
Go Back   网络营销电子商务研究中心 > 服务器与数据库 > MySQL
User Name
Password
 
FAQ Members List Calendar Cheap Glasses Mark Forums Read

Reply
 
Thread Tools Display Modes
  #1   IP: 114.238.173.71
Old 2014-11-26, 06:50 PM
Kahuku Kahuku is offline
初级会员
 
Join Date: 2008-03-08
Posts: 1
Kahuku 现在声名狼藉
Default 如何重置mysql的密码?

如何重置mysql的密码

如果知道密码,则通过以下方式修改;

gaurav@gaurav:~$ mysql --user=root --pass mysql
Enter password:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> exit
Bye

如果忘记密码,则先停止mysql,然后加上参数skip-grant-tables重新启动mysql server

root@gaurav:~# /etc/init.d/mysql stop

Now you should start up the database in the background, via the mysqld_safe command:

root@gaurav:~# /usr/bin/mysqld_safe --skip-grant-tables &
[1] 4271
Starting mysqld daemon with databases from /var/lib/mysql
mysqld_safe[6763]: started

然后登陆mysql,修改密码

root@gaurav:~$ mysql --user=root mysql
Enter password:

mysql> update user set Password=PASSWORD('new-password-here') WHERE User='root';
Query OK, 2 rows affected (0.04 sec)
Rows matched: 2 Changed: 2 Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.02 sec)

mysql> exit
Bye

最后重启mysql server就可以了。

root@gaurav:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld.
Checking for corrupt, not cleanly closed and upgrade needing tables..

用新密码登陆验证下

root@gaurav:~# mysql --user=root --pass=new-password-here
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5 to server version: 5.0.24a-Debian_4-log

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> exit
Bye
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Prescription-glasses.com offers prescription glasses online at discount prices.
All times are GMT +8. The time now is 03:43 AM.


Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.