MySQL open remote access to root, change root password

Source: Internet
Author: User

1.mysql-server only allow native (localhost, 127.0.0.1) to connect access for security reasons. This is not a problem for the site architecture of Web-server and Mysql-server on the same server. However, as the site traffic increases, the late server architecture may place web-server and mysql-server on separate servers for greater performance, at which point Mysql-server is modified to allow web-server remote connections.

2. Do not log on to the server every time to add the modified table, as long as the graphical interface can be remotely managed.

We can modify the following steps as follows:
1, login mysql-server to connect to local Mysql (only local connection is allowed by default)

2. Modify Mysql-server User Configuration

mysql> use MySQL; --Switch to MySQL dbdatabase changedmysql> SELECT user, Password, Host from User; --View existing users, passwords and hosts that are allowed to connect +------+----------+-----------+| User | Password | Host |+------+----------+-----------+|          Root | | localhost |+------+----------+-----------+1 rowInchSet (0.00SEC) Mysql>--Only one default root user, password is empty, only localhost connection is allowed12Mysql>--Below we add a new root user, password is empty, only allow192.168.1.100Connection mysql> GRANT all privileges on * * to‘Root‘@‘192.168.1.100 "identified by  " with GRANT OPTION; mysql>-@ '  ' can be replaced by @ '%  "can be any IP access, of course, we can also update the root user Host directly with update, but not recommended, SQL is as follows:mysql>--Update user SET host=< Span style= "color: #800000;" > ' root "and Host= ' 

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)

MySQL open remote access to root, change root 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.