CentOS system MySQL forgot root user's password

Source: Internet
Author: User

CentOS system MySQL forgot root user's password: First step: (Stop running MySQL)
[Email protected] ~]#/etc/init.d/mysqldstop
Stoppingmysql: [OK] Step two: restart MySQL with the "--skip-grant-tables" parameter [[Email protected] ~]# CD to the MySQL directory, here to the bin directory, will prompt "Please do a CD to the MySQL installation directory and restart"
[Email protected] ~]#./bin/mysqld_safe--skip-grant-tables

[email protected] ~]# starting mysqld daemon withdatabases from/var/lib/mysql

Note: If you stop at this point, clone a new session and proceed to the next step

Step Three: Log in to MySQL with your account
[Email protected] ~]# mysql-u root
Welcome to the MySQL Monitor. Commands end with; or \g.
Your MySQL Connection ID is 1
Server version:5.0.77 Source DistributionType ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer. Fourth step: Change the user database
mysql> use MySQL
Reading table information for completion of table and ColumnNames
Can turn off this feature to get a quicker startup With-aDatabase changed Fifth step: Change the password, the following () within the root123 is Xinmi code
Mysql>update user Set Password=password (' root123 ') whereuser= ' root ';
Query OK, 3 rows affected (0.00SEC)Rows matched:3 changed:3 warnings:0 Sixth step: Refresh the Permissions table
mysql> flush Privileges;
Error 1064 (42000): You have a error in your SQL syntax; Check themanual, corresponds to your MySQL server version for the Rightsyntax-use near ' previleges ' at line 1
Seventh step: Exit MySQL
Mysql> quit
Bye Eighth Step: Restart MySQL
[Email protected] ~]#/etc/init.d/mysqldrestart;
Stoppingmysql: [OK]
Startingmysql: [OK]
Nineth Step: Re-login with a changed password.
[Email protected] ~]# mysql-u root-p
Enter password:admin123
Welcome to the MySQL Monitor. Commands end with; or \g.
Your MySQL Connection ID is 2
Server version:5.0.77 Source DistributionType ' help ', ' or ' \h ' for help. Type ' \c ' to clear the buffer.mysql> quit
Bye

[Email protected] ~]#

Add the following auto-start command/etc/rc.d/init.d/mysqld start

Reprint: http://blog.sina.com.cn/s/blog_4488002e0100z574.html

Reference: http://blog.chinaunix.net/uid-25266990-id-2921603.html

CentOS system MySQL forgot root user's 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.