How to reset the Mysql server root password in Ubuntu _mysql

Source: Internet
Author: User
First stop the MySQL service:
Copy Code code as follows:

root@webserver:/home/webmaster# service MySQL Stop

Then recreate a MySQL service using the Ignore Password Authentication mode:
Copy Code code as follows:

root@webserver:/home/webmaster# mysqld--user=mysql--skip-grant-tables--skip-networking &

Return PID and other startup information after successful startup
Copy Code code as follows:

[1] 3591
root@webserver:/home/webmaster# 121005 2:59:27 [note] Plugin ' federated ' is disabled.
121005 2:59:27 innodb:the InnoDB memory heap is disabled
121005 2:59:27 innodb:mutexes and rw_locks use GCC atomic builtins
121005 2:59:27 innodb:compressed tables use zlib 1.2.3.4
121005 2:59:27 innodb:initializing buffer pool, size = 128.0M
121005 2:59:27 innodb:completed initialization of buffer pool
121005 2:59:27 innodb:highest Supported file format is barracuda.
121005 2:59:27 innodb:waiting for the background threads to start
121005 2:59:28 innodb:1.1.8 started; Log sequence Number 1595685
121005 2:59:28 [note] Mysqld:ready for connections.
Version: ' 5.5.24-0ubuntu0.12.04.1 ' socket: '/var/run/mysqld/mysqld.sock ' port:0 (Ubuntu)

Connect to MySQL System library:
Copy Code code as follows:

root@webserver:/home/webmaster# mysql-u Root MySQL

After connecting to the MySQL library, directly modify the root account password for the new password ' mynewpasswd ':
Copy Code code as follows:

Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.

mysql> Update user Set Password=password (' mynewpasswd ') where user= ' root ';
Query OK, 3 Rows Affected (0.00 sec)
Rows Matched:3 Changed:3 warnings:0

mysql> FLUSH privileges;
Mysql> quit;
Bye

Abort the MySQL service process (PID 3591 See screen information before starting the service):
Copy Code code as follows:

root@webserver:/home/webmaster# Kill 3591

Start the MySQL service normally and log on to the MySQL server successfully with the new password:
Copy Code code as follows:

Root@webserver:/home/webmaster#service MySQL Start
Root@webserver:/home/webmaster#mysql-u root-pmynewpasswd
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.