当前位置:Gxlcms > 数据库问题 > 开启mysql远程登录

开启mysql远程登录

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

首先访问本机的mysql(用ssh登录终端,输入如下命令):

mysql -uroot -p

输入密码登陆进去后,输入如下的语句:

use mysql;
grant all privileges on *.* to user@% identified by password with grant option;

其中:

user是用户名
mysql默认的是root
password是密码自己设置
%表示任意主机,也可以指定ip地址

这样就允许远程任意一台主机访问了。

示例:

grant all privileges on *.* to root@192.168.1.100 identified by ‘‘ with grant option;

即:允许192.168.1.100以root用户无密码登录。

好,就这些了,希望对你有帮助。 

本文github地址:

https://github.com/mike-zhang/mikeBlogEssays/blob/master/2017/20170212_开启mysql远程登录.md

欢迎补充 

开启mysql远程登录

标签:with   输入   访问   blog   地址   nal   href   终端   color   

人气教程排行