重设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 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...

DirectAdmin Installation Guide

...

How to create a partition size larger than 2TB using parted

Linux has a 2TB limit on the partition size. Find the drive you want to partition # fdisk -l...

How to mount ramdisk

创建一个8G的内存文件系统到/var/ram mount -t ramfs -o size=8192m ramfs /var/ram...

How can I add physical volumes to a volume group using LVM?

This article assumes that you have an existing system already using Logical Volume Manager...

Powered by WHMCompleteSolution