If one day you forget the root password, we can use--skip-grant-tables this parameter, specifically implemented as follows:
[Email protected] bin]# mysql-uroot-p
Enter Password:
ERROR 1045 (28000): Access denied for user ' root ' @ ' localhost ' (using Password:yes)
[[email protected] bin]# ps-ef|grep MySQL
Root 7572 2398 0 00:58 pts/1 00:00:00/bin/sh./mysqld_safe--defaults-file=/etc/my.cnf
MySQL 8199 7572 0 00:58 pts/1 00:00:00/usr/local/mysql/bin/mysqld--defaults-file=/etc/my.cnf--basedir=/ Usr/local/mysql--datadir=/data/mysql--plugin-dir=/usr/local/mysql/lib/plugin--user=mysql--log-error=/data/ Mysql/error.log--open-files-limit=3072--pid-file=/data/mysql/he1.pid--socket=/data/mysql.sock--port=3306
Root 8230 2398 0 00:59 pts/1 00:00:00 grep mysql
[Email protected] bin]# kill-9 8199 7572
[[email protected] bin]# ps-ef|grep MySQL
Root 8232 2398 0 00:59 pts/1 00:00:00 grep mysql
[1]+ killed./mysqld_safe--defaults-file=/etc/my.cnf
[[email protected] bin]# ps-ef|grep MySQL
Root 8234 2398 0 00:59 pts/1 00:00:00 grep mysql
[Email protected] bin]# /mysqld_safe--defaults-file=/etc/my.cnf--skip-grant-tables &
[1] 8235
[[email protected] bin] #160317 00:59:43 mysqld_safe Logging to '/data/mysql/error.log '.
160317 00:59:43mysqld_safe starting mysqld daemon with databases From/data/mysql
[Email protected] bin]# mysql-uroot
Welcome to the Mysqlmonitor. Commands End With; or \g.
Your mysqlconnection ID is 1
Server Version:5.6.16-log MySQL Community Server (GPL)
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of the Oracle Corporation and/or its
Affiliates. Othernames may trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> quit
Bye
[[email protected] bin]# MySQL
Welcome to the Mysqlmonitor. Commands End With; or \g.
Your mysqlconnection ID is 2
Server Version:5.6.16-log MySQL Community Server (GPL)
Copyright (c) 2000,2014, Oracle and/or its affiliates. All rights reserved.
Oracle is aregistered trademark of the Oracle Corporation and/or its
Affiliates. Othernames may trademarks of their respective
Owners.
Type ' help ', ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> quit
Bye
This article uses the Kill-9 method, this method does not recommend in the production library to use, the production library should adopt the normal stop the library
This article is from the "Age volt" blog, please make sure to keep this source http://suifu.blog.51cto.com/9167728/1753985
MySQL forgot password what to do