What if I forgot my MySQL admin password?

Source: Internet
Author: User
Tags mysql login

Situation One:

To modify the MySQL admin password in the case of a known password:

mysqladmin-uroot-p123 Password 123456


Situation Two:

In the case of forgetting the MySQL login password, empty or log in to the MySQL admin password:

1. #停止mysqld服务


/etc/init.d/mysqld stop

2. #使用mysqld_safe启动服务器. Starting MySQL will allow anyone to access the MySQL server with a root user and a blank password


#允许本和网络远程登录

/application/mysql/bin/mysqld_safe--skip-grant-tables&

#不允许网络远程登录(recommended)

/application/mysql/bin/mysqld_safe--skip-grant-tables--skip-networking &

3. #使用mysql语句直接登录, no password required here


Mysql

4#. Modifying the password using the MySQL statement, modifying the authorization table


Version 5.6:

Mysql>use MySQL;  Update Mysql.user set Password=password (' 123 ') where user= ' root ' and host= ' localhost '; #把root用户更新密码为 123456

Exit #退出


Version 5.7: Password field changed to Authentication_strings

Update Mysql.user set Authentication_string=password (' 123 ') where user= ' root ' and host= ' localhost ';


5. #然后重启mysql so that the root password for MySQL is modified


/etc/init.d/mysqld restart


What if I forgot my MySQL admin password?

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.