Three ways for MySQL to open remote connections

Source: Internet
Author: User
Tags bind mysql tutorial

This article has a collection of three on how to open the MySQL tutorial remote connection, the first is a MySQL cmd command prompt to open remote connection to MySQL, method Three is to modify the MySQL My.ini file configuration to modify Oh.

Method One

Like to open remote connection to MySQL function?

First link the MySQL of this computer (with SSH login terminal, enter the following command):

mysql-uroot-p

Enter the password login, enter the following statement, execution.

grant all privileges in *.* to ' user ' @ '% ' identified by ' password ' with GRANT option;

Where user is the username, MySQL defaults to root, password is the password set itself. % represents any host. This allows any remote host to be accessed.


Method Two

The MySQL remote feature is opened by the following methods:
Enter MySQL, 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 results and execute:

Use MySQL;
Select Host,user,password from user;

You can see that the ITBC user that you just created is already in the user table. The Host field represents the hosts that are logged on, their values can be IP, or the host name is available, and changing the value of the host field to% means that the ITBC user can log on to the MySQL server on any client machine, and it is recommended that you set it to% at development time.
Update user Set host = '% ' where user = ' ITBC ';

Method Three

MySQL By default is not accessible via remote machines and can be accessed by using the following configuration.

My MySQL environment is UBUNTU+MYSQL5.

1. Modify the/etc/mysql/my.conf, modify the bind-address, designated as the actual IP address of the machine, your My.con modified is probably as follows


[Mysqld]
 

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


2. Login with root MySQL execute the following command


 

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


Sonardb Replace with the name of the database you want to visit, Sonar is the username you want to use, 123456 is replaced with your password, which opens the remote access function.

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.