Linux mysql-5.6 forgot root password, reset root password detailed process

Source: Internet
Author: User
Tags mysql in

The use of MySQL in the Linux platform to forget the root password, for the operation and DBA is a headache, the following explains how to reset the MySQL database root password:

1. Stop the MySQL service process first:

1 service mysqld stop

Then edit the MySQL configuration file my.cnf

1 vim/etc/my.cnf

Find [mysqld] This module:

Add a piece of code on the last side

1 skip-grant-tables   # #忽略mysql权限问题, login directly

Then Save: wq! exit

To start the MySQL service:

1 Service mysqld start

Go directly to the MySQL database:

1Starting MySQL. success!2[[Email protected] ~]# MySQL3 Welcome to the MySQL Monitor. Commands End With; or \g.4Your MySQL ConnectionIDIs15Server version:5.6. theSource Distribution6 7Copyright (c) -, ., Oracle and/or its affiliates. All rights reserved.8 9Oracle is a registered trademark of Oracle Corporation and/or itsTen affiliates. Other names trademarks of their respective One owners. A  -Type'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement. -  theMysql>

Use the MySQL table and then modify the root password for MySQL:

1Mysql>Use mysql; # #使用mysql数据库2Reading table Information forCompletion of table and column names3Can turn off this feature to get a quicker startup with-A4 5 Database changed6mysql> Update user Set Password=password ("123456") Where user="Root"; # #更新密码7Query OK,4Rows Affected (0.00sec)8Rows matched:4Changed:4Warnings:09 TenMysql>Flush privileges;# #刷新权限 OneQuery OK,0Rows Affected (0.00Sec

1[Email protected] ~]#PS-ef |grepMySQL # #显示mysql现有的进程2Root56407      1  0  -: -pts/0    xx:xx:xx/bin/SH/usr/local/mysql/bin/mysqld_safe--datadir=/data/mysql--pid-file=/data/mysql/Web1.pid3Mysql56533  56407  0  -: -pts/0    xx:xx:xx/usr/local/mysql/bin/mysqld--basedir=/usr/local/mysql--datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/data/mysql/web1.err--pid-file=/data/mysql/Web1.pid4Root56560   1737  0  -: -pts/0    xx:xx:xx grepMySQL5[Email protected] ~]#Killallmysqld # #删除mysql现有进程6[Email protected] ~]#PS-ef |grepMySQL7Root56566   1737  0  -: Aboutpts/0    xx:xx:xx grepMySQL8[[Email protected] ~]# Service mysqld start # #重新启动mysql服务9Starting MySQL. success!Ten[Email protected] ~]# Mysql-uroot-P # #使用新密码登录 One Enter Password: A Welcome to the MySQL Monitor. Commands End With; or \g. -Your MySQL ConnectionIDIs1 -Server version:5.6. theSource Distribution the  -Copyright (c) -, ., Oracle and/or its affiliates. All rights reserved. -  -Oracle is a registered trademark of Oracle Corporation and/or its + affiliates. Other names trademarks of their respective - owners. +  AType'Help ;'Or'\h'  forHelp. Type'\c'ToClearThe current input statement. at  -Mysql>

Note: The MySQL service process is turned off, the added skip verification information is deleted, or the database security threat is too large,

Linux mysql-5.6 forgot root password, reset root password detailed process

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.