ubuntu下mysql的启动/停止/重启,以及远程连接设置

来源:互联网 发布:华为云计算部门结构 编辑:程序博客网 时间:2024/05/22 08:27

启动:sudo /etc/init.d/mysql start 停止:sudo /etc/init.d/mysql stop 重启:sudo /etc/init.d/mysql restart


设置远程访问权限步骤:

1、grant all PRIVILEGES on *.* to admin@’%’ identified by ‘123456′;            棕色标记的地方无需空格

2、查看权限设置是否成功:

use information_schema;

select * from user_privileges;

查询到有:'admin’@'%',的结果,说明mysql已经授权远程连接。

3、关闭防火墙

sudo ufw disable

查看防火墙是否已经关闭

ufw status

4、设置mysql的配置文件:

/etc/mysql/my.cnf找到bind-address

在此文件中找到这一行:bind-address=127.0.0.1   ,将红字体的ip设置为本机ip     p.s. 如此设置之后在使用命令行登录mysql时,必须指定确定的ip,否则将无法登录mysql

5、重启mysql