Mysql password retrieval and enabling root Remote Login

Source: Internet
Author: User

I. Restoring the mysql password in Linux

Service mysqld stopmysqld_safe -- skip-grant-tables; ctrl + z pause # Start mysql service mysql-u root-p in safe mode # Use root User Login Without Password ): mysql> use mysql; mysql> update user set password = password ('new password') where user = 'root'; mysql> flush privileges;

Log on to shell again and use the new password!

Ii. mysql password recovery in Windows

1. net stop mysql

2. Switch to the mysql installation directory \ bin.

3. mysqld-nt -- skip-grand-tables

4. Open a new cmd window and enter mysql-u root-p # login without a password

5. update user set password = password ('new password') where user = 'root ';

3. Enable mysql remote Logon

Mysql> grant all privileges on *. * to 'root' @ '%' identified by 'remote password'; # privileges can be omitted

Mysql> flush privileges;

Parameter description:

All: authorize all operation commands to add, delete, modify, and query)

*. *: Authorize all databases and tables.

%: Allow all IP addresses to access mysql

Flush privileges;: refresh the authorization table

Check whether it is enabled. The following message is displayed, indicating that all remote logins are allowed.

Mysql> select host, user, password from user;
| % | Root | * 4ACFE3202A5FF5CF467898FC58AAB1D615029441 |

4. Other commands

Revoke all privileges on *. * from 'root' @ '%'; # revoke the permissions granted to the user;

Show grants;: View Current User Permissions

Show grants for user @ localhost;: view other User Permissions


This article is from the "Linux popular technology" blog, please be sure to keep this source http://going.blog.51cto.com/7876557/1294746

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.