当前位置:Gxlcms > 数据库问题 > 远程连接mysql

远程连接mysql

时间:2021-07-01 10:21:17 帮助过:25人阅读

在window下使用MySQLWorkbench连接Ubuntu服务器下的mysql

1.ubuntu下安装mysql

sudo apt-get install mysql-server

输入密码后即可完成安装

 

2.进入mysql创建远程连接的用户

mysql -u root -p

输入密码登录

使用grant创建用户

grant 权限1,权限2,…权限n on 数据库名称.表名称 to 用户名@用户地址 identified by ‘连接口令‘;

例如:

grant select,insert,update,delete,create,drop on mydb.mytable to hades@192.168.1.88 identified by ‘mypassword‘;
给来自192.168.1.88的用户hades分配可对数据库 mydb的mytable表进行select,insert,update,delete,create,drop等操作的权限,并设定口令为‘mypassword‘;

grant all privileges on *.* to hades@192.168.1.88 identified by ‘mypassword‘;

给来自192.168.1.88的用户hades分配可对所有数据库的所有表进行所有操作的权限限,并设定口令为‘mypassword‘;

grant all privileges on *.* to hades@‘%‘ identified by ‘mypassword‘;

给来自任何IP地址的用户hades分配可对所有数据库的所有表进行所有操作的权限限,并设定口令为‘mypassword‘;

 

3.修改mysql的配置文件

sudo vim /etc/mysql/my.cf

找到bind-address = 127.0.0.1

改成bind-address = 0.0.0.0

保存退出

 

4.重启mysql服务

sudo service mysql restart

 

5.在window下使用mysqlworkbench连接

技术分享

 

 6.显示如下即为连接成,如不成功,请查看服务器端口3306是否打开。

技术分享

 

远程连接mysql

标签:ice   tar   ip地址   远程   9.png   退出   数据   安装   etc   

人气教程排行