Modify the root password of MySQL in Centos

Source: Internet
Author: User

Method 1: log on to the system as the root user/usr/local/mysql/bin/mysqladmin-u root-p password. New password: enter password. Old password
Method 2: log on to the mysql database as the root user and update mysql. user set password = password ("new password") where User = "root"; mysql> flush privileges; mysql> quit;
What should I do if I forget the root password of mysql?
If MySQL is running, first stop the mysql process: killall mysqld to start MySQL (abnormal startup ): /usr/local/mysql/bin/mysqld_safe-skip-grant-tables & in this way, you can enter MySQL without a password: /usr/local/mysql/bin/mysql-u root-p (press Enter when the password is required) mysql> update user mysql. set password = password ("new password") where user = "root"; mysql> flush privileges; mysql> quit; restart the process: killall mysqld start MySQL in Normal Mode: /usr/local/mysql/bin/mysqld_safe-user = mysql &
Note: In the update statement, the password = password ("new password") is only used to replace the three words with the password we want to set. Others are written as they are, the reason for my previous failure was that the parentheses and the previous password were omitted. their role is to store passwords in the database in encrypted form.

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.