Home > Database > Mysql Tutorial > body text

Linux下配置MySQL远程访问

WBOY
Release: 2016-06-07 17:07:33
Original
1000 people have browsed it

MySQL默认是不可以通过远程机器访问的,通过下面的配置可以开启远程访问. 我的MySQL环境是Ubuntu 10.04+MySQL 5.1 1.修改/etc/m

MySQL默认是不可以通过远程机器访问的,通过下面的配置可以开启远程访问.

我的MySQL环境是Ubuntu 10.04+MySQL 5.1

1.修改/etc/my.conf,修改完大概是如下的样子

[mysqld]
default-character-set=utf8
#修改bind-address,指定为本机实际IP地址
bind-address    = 本机地址
#指定运行mysql进程的用户
user            = mysql
#mysql监听的端口
port            = 3306
#安装的目录
basedir         = /extra-root/mysql-db
#数据文件所在目录
datadir         = /extra-root/db-data
tmpdir          = /tmp

2.用root登陆mysql:

sudo mysql -u root -p

执行如下命令

grant all on 数据库名.* to 用户名@'客户端IP地址' identified by '密码';

#使root能够从任意主机上进行访问

sonardb替换为你想访问的数据库名,sonar是你的想使用的用户名,123456替换为你的密码,这样就开启了远程访问功能。

linux

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template