Home > Database > Mysql Tutorial > ubuntu下配置MySQL服务_MySQL

ubuntu下配置MySQL服务_MySQL

WBOY
Release: 2016-06-01 13:12:01
Original
949 people have browsed it

Ubuntu

第一步 安装MySQL

sudo apt-get install mysql-server

第二步 配置MySQL

2.1 vim /etc/mysql/my.cnf 找到bind-address = 127.0.0.1。

2.2 注释掉: #bind-address = 127.0.0.1

或者把IP改为 0.0.0.0:bind-address = 0.0.0.0 允许任意IP访问

2.3 重启 mysql服务: sudo /etc/inid.d/mysql restart

第三步 授权用户能进行远程连接

3.1 登录mysql:mysql -u root -p,输入密码登录

3.2 授权

grant all privileges on *.* to root@"%" identified by "password" with grant option;

flush privileges;
第一行命令解释如下,*.*:第一个*代表数据库名;第二个*代表表名。这里的意思是所有数据库里的所有表都授权给用户。root:授予root账号。“%”:表示授权的用户IP可以指定,这里代表任意的IP地址都能访问MySQL数据库。“password”:分配账号对应的密码,这里密码自己替换成你的mysql root帐号密码。


第二行命令是刷新权限信息,也即是让我们所作的设置马上生效。

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