How can I forget the root password of mysql under the Centos server?

Source: Internet
Author: User
Tags centos server

1. Modify MySQL Logon Settings:

# Vi/etc/my. cnf adds the following sentence to the [mysqld] section: skip-grant-tables for example: [mysqld] datadir =/var/lib/mysqlsocket =/var/lib/mysql. save sockskip-grant-tables and exit vi. 2. restart mysqld #/etc/init. d/mysql restartStopping MySQL: [OK] Starting MySQL: [OK] 3. log on to and modify the MySQL root Password #/usr/bin/mysqlWelcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 3 to server version: 3.23.56Type 'help; 'or' \ H' for help. type '\ C' to clear the buffer. mysql> USE mysql; Reading table information for completion of table and column namesYou can turn off this feat Ure to get a quicker startup with-ADatabase changedmysql> UPDATE user SET Password = password ('new-password') WHERE User = 'root'; Query OK, 0 rows affected (0.00 sec) Rows matched: 2 Changed: 0 Warnings: 0 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql> quitBye4. modify the MySQL Logon Settings # vi/etc/my. cnf deletes and saves the skip-grant-tables added to the [mysqld] segment and exits vi. 5. Restart mysqld #/etc/init. d/mysql restartStopping MySQL: [OK] Starting MySQL: [OK]


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.