MySQL Reset password

Source: Internet
Author: User

MySQL Reset password

Wulilidemacbook-pro:bin wulili$ MySQL Start

ERROR 1045 (28000): Access denied for user ' wulili ' @ ' localhost ' (using Password:no)

Wulilidemacbook-pro:bin wulili$ Su-root

1. mysql Service off

2.

Start Mysqld_safe and skip the start authorization table. 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 &


Wulilidemacbook-pro:support-files root# Find/-name Mysqld_safe

Find:/DEV/FD/3: Not a directory

Find:/DEV/FD/4: Not a directory

/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe

Wulilidemacbook-pro:support-files root# /usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe-- Skip-grant-tables &

[1] 1397

Wulilidemacbook-pro:support-files root# 2016-11-30t11:47:40.6nz mysqld_safe Logging to '/usr/local/mysql/data/ Wulilidemacbook-pro.local.err '.

2016-11-30t11:47:40.6nz Mysqld_safe starting mysqld daemon with databases From/usr/local/mysql/data

Mysql-uroot-p

Enter Password: press ENTER

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 2

Server version:5.7.16 MySQL Community Server (GPL)


Copyright (c), Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names trademarks of their respective

Owners.


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


mysql> Update user Set Password=password (' 12345678 ') where user= "root";

ERROR 1046 (3d000): No Database selected

mysql> use mysql;

Reading table information for completion of table and column names

Can turn off this feature to get a quicker startup with-a


Database changed

mysql> Update user set Password=password (' 12345678 ') where user= "root";

ERROR 1054 (42S22): Unknown column ' Password ' in ' Field list '

mysql> Update user Set Passwd=password (' 12345678 ') where user= "root";

ERROR 1054 (42S22): Unknown column ' passwd ' in ' Field list '

mysql> Update user Set Password=password (' 12345678 ') where user= ' root ';

ERROR 1054 (42S22): Unknown column ' Password ' in ' Field list '

mysql> Update user set Authentication_string=password (' 12345678 ') where user= "root";

Query OK, 1 row affected, 1 warning (0.01 sec)

Rows matched:1 changed:1 warnings:1


mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)


Mysql> quit

Bye

3. Restart the database

Wulilidemacbook-pro:support-files root#/usr/local/mysql/support-files/mysql.server Restart

Shutting down MySQL

.. 2016-11-30t11:58:22.6nz mysqld_safe mysqld from PID File/usr/local/mysql/data/wulilidemacbook-pro.local.pid ended

success!

Starting MySQL

. success!

[1]+ Done/usr/local/mysql-5.7.16-osx10.11-x86_64/bin/mysqld_safe--skip-grant-tables

Wulilidemacbook-pro:support-files root# mysql-u root-p Here, the code is 12345678.

Enter Password:

Welcome to the MySQL Monitor. Commands End With; or \g.

Your MySQL Connection ID is 4

Server version:5.7.16


Copyright (c), Oracle and/or its affiliates. All rights reserved.


Oracle is a registered trademark of the Oracle Corporation and/or its

Affiliates. Other names trademarks of their respective

Owners.


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


Mysql> quit

Bye

Wulilidemacbook-pro:support-files root#




mysql> use MySQL;

ERROR 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.

mysql> alter user ' root ' @ ' localhost ' identified by ' 12345678 ';

Query OK, 0 rows affected (0.01 sec)


mysql> flush Privileges;

Query OK, 0 rows Affected (0.00 sec)


mysql> show databases;

+--------------------+

| Database |

+--------------------+

| Information_schema |

| MySQL |

| Performance_schema |

| SYS |

+--------------------+

4 rows in Set (0.00 sec)



MySQL Reset 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.