Three methods for enabling remote connection in mysql

Source: Internet
Author: User

This article has added three methods for enabling mysql remote connection. The first method is to enable mysql remote connection at the mysql cmd command prompt. The third method is to modify mysql my. ini file configuration.

This article adds three typesEnable mysql remote connection,The first one is to enable remote connection for mysql at the mysql cmd command prompt. The third method is to modify the file configuration of mysql my. ini.

Method 1

How can I enable the remote connection function for mysql?

First, connect to the local mysql (log on to the terminal using ssh and enter the following command ):

Mysql-uroot-p

Enter the password to log in, and enter the following statement to execute.

Grant all privileges on *. * to 'user' @ '%' identified by 'Password' with grant option;

Here, user is the user name, mysql is the root by default, and password is set by yourself. % Indicates any host. This allows remote access from any host.


Method 2

How to enable the mysql remote FunctionAs follows:
Go to mysql and create a new user itbc:
Format: grant permission on Database tutorial name. Table name user @ login host identified by "User Password ";

Grant select, update, insert, delete on *. * to itbc@192.168.88.234 identified by "itbc1234 ";


 
View the result and execute:

Use mysql;
Select host, user, password from user;

You can see that you have created an itbc user in the user table. The host field indicates the host to be logged on. The value can be an ip address or a host name. Changing the value of the host field to % indicates that the host can be logged on to the mysql server as an itbc user on any client machine, we recommend that you set it to % during development.
Update user set host = '%' where user = 'itbc ';

Method 3

By default, mysql cannot be accessed through a remote machine. You can enable remote access through the following configuration.

My mysql environment is ubuntu + mysql5

1. Modify/etc/mysql/my. conf, bind-address, and specify as the actual IP address of the Local Machine. After modifying your my. con, it looks like the following:


[Mysqld]
 

#
# * Basic settings
#
Default-character-set = utf8
Default-storage-engine = innodb
Bind-address = 192.168.1.107
User = mysql
Pid-file =/var/run/mysqld. pid
Socket =/var/run/mysqld. sock
Port = 3306
Basedir =/usr
Datadir =/var/lib/mysql
Tmpdir =/tmp
Language =/usr/share/mysql/english
Skip-external-locking


2. log on to mysql using root and execute the following command:


 

Grant all on sonardb. * to sonar @ '%' identified by '123 ';
Grant all on sonardb. * to sonar @ localhost identified by '20140901 ';


Sonardb replaces the name of the database you want to access. sonar is the username you want to use, and 123456 is replaced with your password. This enables remote access.

 

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.