Change the root password and restore the MySQL root user

Source: Internet
Author: User
Tags mysql query mysql tutorial

Change root password and restore MySQL tutorial root user
I accidentally deleted the MySQL root account. What am I going to do? "and" I lost my root password? This problem is met, then you touch this kind of problem is to back up the data, reinstall MySQL and restore all the database tutorial files? We'll find a better way for you now.

1, stop MySQL,
2, server Permissions
C:www.111cn.netbinmysqld-nt.exe--skip-grant-tables
Where c:www.111cn.net is MySQL ' instalation directory.
If it's Linux, execute the following command
/usr/local/mysql/bin/mysqld_safe--skip-grant-tables--user=root--skip-networking
3, connect to the server using the exsisting account (root or some otherif root account is deleted).
C:www.111cn.netbinmysql.exe-u User
Or
/usr/local/mysql/bin/mysql-u User

4, change the MySQL query password
Update Mysql.user set Password=password (' Newpwd ') where user= ' root ';
or recreating User:
Create user root identified by password ' newpwd ';
Grant all privileges on *. * to ' root ' @ ' localhost ' identified by ' newpwd ' with GRANT option Max_queries_per_hour 0 max_connections_per_hour 0 max_up Dates_per_hour 0 max_user_connections 0;

5, Refresh Permissions
Flush privileges;

6. Reboot the server
OK mysql root password you get back to the ha.

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.