How can I modify the password of the root account of the MySQL database?

Source: Internet
Author: User

I forgot the password of the root account of the MySQL database. How can I modify the background:
MySQL Database root Account is generally known only to MySQL DBAs, And the password of this account must be kept strictly confidential. Once the leakage is serious, however, if DBAs forget, some MySQL management cannot be performed, at this time, you must reset the root account password without any damage to ensure data security: www.2cto.com
1. stop mysqld Database service shell> service mysql stop Note: if you have the shutdown permission, you can use mysqladmin -- user = xxx-password shutdown to stop mysqld service 2. start mysqld Database Service shell> mysqld -- datadir =/var/data/-- pid-file =/var/data/xxx with the -- skip-grant-tables option. pid -- skip-grant-tables Note: datadir specifies the database data directory, pid-file specifies the file whose content is mysqld process number, and skip-grant-tables specifies the options, ignore permission verification during mysqld startup 3. do not use the password to log on to mysql database shell> mysql-uroot mysql. Note: if the password option (-p or -- password) is not specified, use a blank password to log on. 4. modify the account root password mysql> update user set password = password ('root _ pwd') where user = 'root'; mysql> flush privileges; Note: After the password is changed, you must use the flush privileges statement to make the password take effect. Here, set the root account password to root_pwd www.2cto.com 5. stop mysqld Database service shell> mysqladmin -- user = root-password shutdown Note: This time mysqladmin is used to stop. in linux, the service cannot stop the mysql database server that is manually started. 6. start mysql database shell> service mysql start 7 normally. log on with the new password and find that the password has been changed to the new password shell> mysql-uroot-proot_pwd mysql author chhuma

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.