重设MySQL root密码

如果忘记了MySQL的root密码,可以用以下方法重新设置:

1. KILL掉系统里的MySQL进程;

killall -TERM mysqld

2. 用以下命令启动MySQL,以不检查权限的方式启动;

mysqld_safe -skip-grant-tables &

3. 然后用空密码方式使用root用户登录 MySQL;

mysql -u root

4. 修改root用户的密码;

mysql> update mysql.user set password=PASSWORD('new-password') where User='root';

mysql> flush privileges;

mysql> quit

重新启动MySQL,就可以使用新密码登录了.

 

或者也可以用mysqladmin命令来修改密码:

mysqladmin -u root -p password mypasswd

输入这个命令后,需要输入root的原密码,然后root的密码将改为mypasswd。 把命令里的root改为你的用户名,你就可以改你自己的密码了。

 

这个回答有用吗?

 打印这篇文章

继续阅读

How to Modify Running Services in CentOS, RedHat, and Fedora Distributions

To enable services in CentOS, RedHat, and Fedora distributions, you can determine a service and...

Change DirectAdmin's password

Direct Admin; by default automatically creates an administrator account when it's initially...

How to mount a secondary/additional harddrive

For centos/fedora run "fdisk -l" to see what drives are recognized by the server. find the...

How to open ports within IPtables in Redhat 3/4/5 & Above | CentOS | Fedora Linux

How to open ports within IPtables in Redhat 3/4/5 & Above | CentOS | Fedora LinuxIPtables...

rsync and ssh on a different port

If the server is using port 8023 for ssh then try using this command to use with rsyncrsync -av...

Powered by WHMCompleteSolution