Home > Database > Mysql Tutorial > body text

忘记了mysql的root密码重置方法

WBOY
Release: 2016-06-07 17:51:39
Original
1394 people have browsed it

如果不记得root密码了我们只要修改mysql中user表中的root用户的password改成你的新密码然后刷新权限就好了。

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

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

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

  d_safe -skip-grant-tables &

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

  mysql -u root

  4. 修改root用户的密码;

        mysql> update mysql.user set password=PASSWORD('新密码') where  User='root';

        mysql> flush privileges;

        mysql> quit

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

上面讲述的是利用sql命令来实现,其实我们还可以通过替换mysql use表现修改用户密码方法也差不多,我以前(在同版本号mysql下做过替换 mysql这种做法,如果个数据库里面的数据库不同就千万别操作)。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!