Home >Database >Mysql Tutorial >Enable Mysql remote access

Enable Mysql remote access

高洛峰
高洛峰Original
2016-12-02 14:33:111154browse

Mysql cannot be accessed through remote machines by default. Remote access can be enabled through the following configuration.

My MySQL environment is ubuntu+mysql5

1. Modify /etc/mysql/my.conf, modify bind-address, and specify it as the actual IP address of the machine. After modification, your my.con will probably look like the following

[mysqld]

# .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. Log in to mysql as root and execute the following command

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

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

Replace sonardb with the database name you want to access, sonar is the user name you want to use, and replace 123456 with your Password, thus enabling the remote access function.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn