Mysql enables remote access to the root user and modifies the root password.

Source: Internet
Author: User
1. mySql-Server only allows access from the Local Machine (localhost, 127.0.0.1) for security reasons. this is no problem for the website architecture of both Web-Server and MySql-Server on the same Server. however, as website traffic increases, the Server architecture may separate Web-Server and MySql-Server

1. mySql-Server only allows access from the Local Machine (localhost, 127.0.0.1) for security reasons. this is no problem for the website architecture of both Web-Server and MySql-Server on the same Server. however, as website traffic increases, the Server architecture may separate Web-Server and MySql-Server

1. mySql-Server only allows access from the Local Machine (localhost, 127.0.0.1) for security reasons. this is no problem for the website architecture of both Web-Server and MySql-Server on the same Server. however, as the website traffic increases, the Server architecture may put the Web-Server and MySql-Server on independent servers in the later stage to improve the performance, in this case, MySql-Server must be modified to allow Web-Server for remote connection.

2. You do not need to log on to the server every time to add and modify tables. You can use a graphical interface to remotely manage the tables.

We can follow the steps below to modify:
1. log on to Mysql-Server to connect to local mysql (only local connections are allowed by default)

2. Modify the user configuration of Mysql-Server.

Mysql> USE mysql; -- switch to mysql DBDatabase changedmysql> SELECT User, Password, Host FROM user; -- view existing users, password and Host + ------ + ---------- + ----------- + | User | Password | Host | + ------ + ---------- + ----------- + | root | localhost | + ------ + ---------- + ----------- + 1 row in set (0.00 sec) mysql> -- only one default root user, the password is empty, and only localhost is allowed to connect to 12 mysql> -- Next we will add another root user, and the password is empty, only 192.168.1.100 is allowed to connect to mysql> grant all privileges on *. * TO 'root' @ '192. 168.1.100 'identified BY ''' with grant option; mysql> -- @ '192. 168.1.100' can be replaced with @ '%' to access any ip address. Of course, we can also directly UPDATE the root user Host with UPDATE, but it is not recommended. The SQL is as follows: mysql> -- UPDATE user SET Host = '2017. 168.1.100 'where User = 'root' AND Host = 'localhost' LIMIT 1;

Mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

Change root Password

mysql> use mysql

Database changed

mysql> update user set password=PASSWORD('123456')where user='root';

Query OK, 0 rows affected (0.00 sec)

Rows matched: 1 Changed: 0 Warnings: 0

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

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.