MySQL deleted the user table, forgot root password

Source: Internet
Author: User
Tags mysql login

Delete the wrong user table root can not even go up, and then we can understand the root password do not know, forget. Use this method to retrieve root and recreate the deleted user. Fortunately not on the line ... 1. Modify the login settings for MySQL:#vim/etc/my.cnfAdd a sentence to the paragraph in [mysqld]: skip-grant-Tables For example: [Mysqld] DataDir=/var/lib/MySQL Socket=/var/lib/mysql/Mysql.sock Skip-grant-tables Save and Exit VI. 2. Restart Mysqld#Service mysqld Restartstopping MySQL: [OK] starting MySQL: [OK]3. Log in and modify the root password of MySQL#MySQLWelcome to the MySQL Monitor. Commands End With;or\g. Your MySQL Connection ID is3 to Server version:3.23.56Type'Help ;' or '\h'  forHelp. Type'\c'To clear the buffer. mysql>Use MySQL; Database changed MySQL> UPDATE user SET Password = Password ('New-password') WHERE User ='Root' ; Query OK, 0 rows affected (0.00sec) Rows matched:2changed:0 warnings:0 MySQL>flush Privileges; Query OK, 0 rows affected (0.01sec) MySQL>quit4. Change MySQL login settings back#vim/etc/my.cnfAdd the skip-grant-that you just added in the [MYSQLD] paragraphTables Delete Save and exit Vim5. Restart Mysqld#Service mysqld Restartstopping MySQL: [OK] starting MySQL: [OK]

MySQL deleted the user table, forgot root 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.