Reset MySQL Password

Source: Internet
Author: User

?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 如何修改mysql root密码   忘记MySQL ROOT密码是在MySQ使用中很常见的问题,可是有很多朋友并不会重置ROOT密码,那叫苦啊,特写此文章与大家交流: 1、编辑MySQL的配置文件:my.ini 一般在MySQL安装目录下有my.ini即MySQL的配置文件。 在此配置文件的最后添加如下一行: skip-grant-tables 保存退出编辑。 2、然后重启MySQL服务 在命令行下执行: net stop MySQL net start MySQL 3、设置新的ROOT密码 然后再在命令行下执行: MySQL -u root -p MySQL或mysql -u root -p 直接回车无需密码即可进入数据库了。 此时,在命令行下执行 use mysql; 现在我们执行如下语句把root密码更新为: update user set password=PASSWORD("root") where user=‘root‘;(注意:此时不用使用mysqladmin -u root -p password ‘你的新密码‘这条命令修改密码,因为‘skip-grant-tables‘配置, 不信的话,你可以试用一下,它肯定会报如下所示的错误: F:\Documents and Settings\long>mysqladmin -u root -p password ‘root‘ Enter password: Warning: single quotes were not trimmed from the password by your command line client, as you might have expected. mysqladmin: You cannot use ‘password‘ command as mysqld runs  with grant tables disabled (was started with --skip-grant-tables). Use: "mysqladmin flush-privileges password ‘*‘" instead) exit 退出MySQL。 4、还原配置文件并重启服务然后修改MySQL配置文件把刚才添加的那一行‘skip-grant-tables‘删除。 再次重起MySQL服务,密码修改完毕。

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.