How to enable MySQL database remote connection

Source: Internet
Author: User

How to enable MySQL database remote connection

Sometimes it is not possible to remotely connect to the MySQL database. You can refer to the following method to solve the problem.

1. log on to the MySQL database of your machine: mysql-uroot-p Password

Set the root user to access any IP address. The Code is as follows (optional, Here % represents any, you can also specify an IP address ):

MySQL> update user set host = '%' where user = 'root ';
MySQL> select host, user from user;


2. MySQL> grant all privileges on *. * TO 'root' @ '%' identified by 'mypassword' with grant option;

Grant data access permissions to any host

3. MySQL> flush privileges;

Modification takes effect

4. MySQL> EXIT

Log out of the MySQL server

In this way, you can log on to any other host as the root user!

Enter the IP address and port number on other machines (default port: 3306 ).

C: \ Users \ XXXXX> mysql-uroot-proot-h192.168.0.3-P3307
Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 936
Server version: 5.5.28 MySQL Community Server (GPL)

Copyright (c) 2000,201 4, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.

Type 'help; 'or' \ H' for help. type' \ C' to clear the current input statement.

Mysql>

This article permanently updates the link address:

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.