MySQL user modifies login password and opens remote login

Source: Internet
Author: User

First, modify the user login password:

mysql> show databases;
ERROR 1820 (HY000): Must SET PASSWORD before executing this statement
Mysql> quit
Bye
[[email protected] ~]# mysqladmin-uroot-p password--change user password
Enter Password:
New Password:
Confirm New Password:

[[email protected] ~]# mysql-uroot-p--Login with new password
Enter Password:
Welcome to the MySQL Monitor. Commands End With; or \g.
......
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| Information_schema |
| MySQL |
| Performance_schema |
| Test |
+--------------------+
4 rows in Set (0.10 sec)


Second, open the user remote login permission
---Add-H parameter remote login MySQL database prompt the following error
C:\users\administrator>mysql-uroot-p-h192.168.1.204
Enter Password: * * * *
ERROR 1130 (HY000): Host ' 192.168.1.123 ' isn't allowed to connect to this MySQL server
Error Analysis: Host ' 192.168.1.123 ' does not allow connection to MySQL database (no permissions).

[[email protected] ~]# myslq-uroot-p--Local login
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> select User,password,host from User;---To view users ' information, it is true that the root account only allows local login.
+------+-------------------------------------------+-------------+
| user | password | host |
+------+-------------------------------------------+-------------+
| root | * 76c1b58de0f08b3169e76cedd6dd814b32a36f78 | localhost |
| root | *76c1b58de0f08b3169e76cedd6dd814b32a36f78 | rhel204.com |
| root | *76c1b58de0f08b3169e76cedd6dd814b32a36f78 | 127.0.0.1 |
| root | *76c1b58de0f08b3169e76cedd6dd814b32a36f78 |:: 1 |
+------+-------------------------------------------+-------------+
4 rows in Set (0.00 sec)

Mysql> Grant all privileges on * * to [e-mail protected] '% ' identified by ' Rusky ';--Authorization
Query OK, 0 rows affected (0.03 sec)
Or: Grant all on db1.* to [email protected] '% '; --Authorized user username1 telnet to the database db1 from either client and allows all operations to the library DB1.
"%" means that any host can log on remotely to the server for access.
*. * represents all objects for all libraries.
If you want to restrict access to only one machine, replace% with the appropriate IP, such as:
GRANT all privileges on * * to [email protected] ' 192.168.1.123 '; --can omit identified by ' password ' or with GRANT option;

Mysql> flush privileges;--Refresh Permissions
Query OK, 0 rows affected (0.04 sec)

c:\users\administrator>mysql-uroot-p-h192.168.1.204--root Account Login
Enter Password: * * * *
Welcome to the MySQL Monitor. Commands End With; or \g.
......
Mysql>

Third, restrict the user's permissions when creating a user:

Create user ' lxj ' @ '% ' identified by ' 123123 ';

The @ after parameter specifies on which host the user can log on, if localhost is available to the local user, you can use the wildcard% if you want the user to be able to log on from any remote host.

MySQL user modifies login password and opens remote login

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.