MySQL modifies user password and permission limit settings

Source: Internet
Author: User
Tags flush mysql in mysql login phpmyadmin

Use phpMyAdmin to change the root password

Use phpMyAdmin to change the MySQL root password is very convenient, installation configuration good phpmyadmin, first login admin interface, click on the right to modify the password link, enter you want to modify the MySQL root new password, the last click to execute it,


Notice here phpMyAdmin default is not allowed MySQL root default password for null login, if you accidentally modify the password interface to choose a blank password, you need to modify the phpMyAdmin configuration file to login phpMyAdmin to implement the change MySQL The function of the root password. Specific how to modify the next time I will explain.


Use mysqladmin input:

Mysqladmin-u root-p OldPassword newpasswd

After executing this command, you need to enter the original password of root, so that the root password will be changed to NEWPASSWD. Similarly MySQL or you have no way to execute mysqladmin, then this method is invalid, and mysqladmin cannot empty the password.

The following methods are used at the MySQL prompt and must have the root permissions of MySQL.


Method Three:

The code is as follows Copy Code

Mysql> INSERT into Mysql.user (Host,user,password) VALUES ('% ', ' system ', Password (' manager ')); Mysql> FLUSH Privileges

Specifically, this is adding a user named system with a password of manager. Note that you want to use the password function, and then use flush privileges to perform the validation.

Method Four:

As with method Three, only the Replace statement is used:

The code is as follows Copy Code

Mysql> REPLACE into Mysql.user (Host,user,password) VALUES ('% ', ' system ', Password (' manager ')); Mysql> FLUSH Privileges

Method Five:

Use the Set Password statement:

The code is as follows Copy Code

Mysql> SET PASSWORD for system@ "%" = PASSWORD (' manager ');

You must also use the password () function, but you do not need to use flush privileges to perform the validation.

Root password forgot to solve the solution in Linux


1. First, verify that the server is in a secure state, that is, no one can arbitrarily connect to the MySQL database.
Because the MySQL database is completely out of password protected during the reset of the MySQL root password
State, other users can also arbitrarily log in and modify MySQL information. You can use the MySQL pair
Port is closed, and the method of stopping Apache and all user processes to implement the server's quasi-security
State. The safest state is to operate on the console of the server and unplug the network cable.
2. To modify MySQL login settings:
# VI/ETC/MY.CNF
In the paragraph of [mysqld], add a sentence: Skip-grant-tables
For example:

The code is as follows Copy Code
[Mysqld]
Datadir=/var/lib/mysql
Socket=/var/lib/mysql/mysql.sock
Skip-grant-tables

Save and Exit VI.
3. Reboot mysqld

The code is as follows Copy Code
#/etc/init.d/mysqld Restart
stopping MySQL: [OK]
Starting MySQL: [OK]

4. Log in and modify the MySQL root password

  code is as follows copy code
#/usr/bin/mysql
Welcome to the MySQL monitor. Commands End With; or G.
Your MySQL Connection ID is 3 to server version:3.23.56
Type ' help. Type ' C ' to clear the buffer.
mysql> use MySQL;
Reading table information for completion of table and column names
You can turn off this feature to get a Quicke R startup with-a
Database changed
mysql> UPDATE user SET Password = Password (' New-password ') WHERE user = ' Root ';
Query OK, 0 rows Affected (0.00 sec)
Rows matched:2 changed:0 warnings:0
mysql> flush; privileges r> Query OK, 0 rows affected (0.01 sec)
Mysql> quit
Bye

5. Change the MySQL login settings back
# VI/ETC/MY.CNF
Delete the skip-grant-tables that you just added in the [mysqld] section
Save and Exit VI.
6. Reboot mysqld

The code is as follows Copy Code
#/etc/init.d/mysqld Restart
stopping MySQL: [OK]
Starting MySQL: [OK]

Work for fun,live for love!


find MySQL password in Windows


Method Two:

First in the MySQL installation directory to create a new pwdhf.txt, input text: SET PASSWORD for ' root ' @ ' localhost ' = PASSWORD (' * * *);

Red part for new password to be set
Stop the MySQL service with the Windows Service Management tool or Task Manager (Task Manager k off the MYSQLD-NT process)
DOS command prompt to the bin directory under the MySQL installation directory like my is D:program filesmysqlmysql Server 5.1bin
Then run: Mysqld-nt--init-file=. /pwdhf.txt
Complete stop MySQL database service (Task Manager k off Mysqld-nt process), and then restart in normal mode MySQL can be

How to set access restrictions in MySQL


Enter into the MySQL execution directory (usually c:mysql in). Enter Mysqld-shareware.exe, enter MySQL--user=root MySQL, otherwise cannot add new user. Go to the mysql> prompt to do the operation.

Let's say we're going to build a superuser, the username is system, and the user password is manager.

Method One:

With the grant command authorization, enter the following code:

The code is as follows Copy Code
Mysql>grant all privileges in *.* to System@localhost identified by ' manager ' with GRANT OPTION;

Should be shown: Query OK, 0 rows affected (0.38 sec)

Method Two:

To set each permission for a user:

  code is as follows copy code

  Mysql>insert into user VALUES (' localhost ', ' system ', PASSWORD (' manager '), ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y ', ' y-axis ', ' y-axis ', ' Y ' , ' y ', ' y ', ' y ', ' y ');

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.