MySQL forgot root password

Source: Internet
Author: User

First you need to log in to the server where MySQL is installed

1. Stop the MySQL service

# Service Mysqld Stop

(My server is using the compilation installed MySQL, did not find the corresponding mysqld, I directly use the kill process to kill MySQL)

2. Skip the Startup authorization form and start MySQL

There are two ways of doing this:

1. Modify MY.CNF (My.ini)

# The MySQL server[mysqld]port             3306 Socket           =/var/lib/mysql/mysql.sock#add line#skip-grant-tables

2. Start Mysqld_safe and skip the start authorization form. The Skip-grant-tables parameter at startup is designed to not start the Grant-tables, authorization table when MySQL is started. This will allow you to change the root password.

# Mysqld_safe--skip-grant-tables &

3. Log in to MySQL and change the password

1 mysql-uroot-p      ---- require a password, you can enter it directly.  2usemysql; 3 set password=password ('12345678'where user="Root ";    --- set the root password to 123456784flush privileges; 5 quit

4. Kill the Mysqld_safe process and restart the mysqld.

Service mysqld Start

My server is in/usr/bin/mysqld_safe.

    

MySQL forgot root password

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.