Mysql open remote connection of the three methods

Source: Internet
Author: User
Keywords Network programming Mysql tutorial
Tags access address configuration file function host how to link

This article is a collection of three on how to open the mysql tutorial remote connection, the first paragraph is to mysql cmd command prompt to open the remote connection to mysql, the third method is to modify the mysql my.ini file configuration to modify the oh.

method one

Like to open mysql remote connection function?

First link the machine's mysql (use ssh login terminal, enter the following command):

mysql -uroot-p

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

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

Among them, the user is the user name, mysql acquiescence is the root password is the password to set their own. % Means any host. This allows any remote host to access it.


Method Two

Open mysql remote function as follows:
Into mysql, create a new user itbc:
Format: grant permissions on the database tutorial name. Table users @ login host identified by "user password";

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



View the results, execute:

use mysql;
select host, user, password from user;

You can see in the user table has just created itbc users. host field indicates the host login, the value can be ip, host name can be used, the host field value changed to% on any client machine to itbc user to log in to the mysql server, it is recommended that the development of% .
update user set host = '%' where user = 'itbc';

Method three

mysql acquiescence can not be accessed through the remote machine, through the following configuration can open the remote access.

My mysql environment is ubuntu + mysql5

1. Modify /etc/mysql/my.conf, modify the bind-address, designated as the actual ip address of this machine, your my.con revised finished probably look 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/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 root login 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 the database name you want to visit, sonar is the user name you want to use, 123456 replaced with your password, thus opening 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.