mysql允许外网访问以及修改mysql账号密码实操方法
mysql的root账户,我在连接时通常用的是localhost或127.0.0.1,公司的测试服务器上的mysql也是localhost所以我想访问无法访问,测试暂停.
解决方法如下:
1,修改表,登录mysql数据库,切换到mysql数据库,使用sql语句查看"select host,user from user ;"
mysql -u root -pvmwaremysql>use mysql; mysql>update user set host = '%' where user ='root'; mysql>select host, user from user; mysql>flush privileges;
注意:最后一句很重要,目的是使修改生效.如果没有写,则还是不能进行远程连接.
2,授权用户,你想root使用密码从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'admin123' WITH GRANT OPTION; flush privileges;
如果你想允许用户root从ip为192.168.1.104的主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.104' IDENTIFIED BY 'admin123' WITH GRANT OPTION; flush privileges;
修改MySql密码
在MySQL 5.7 password字段已从mysql.user表中删除,新的字段名是“authenticalion_string”.
选择数据库:
use mysql;
更新root的密码:
update user set authentication_string=password('新密码') where user='root' and Host='localhost';
刷新权限:
flush privileges;
相关推荐
要啥自行车一把梭 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
emmm00 2020-11-17
王艺强 2020-11-17
aydh 2020-11-12
世樹 2020-11-11
zry 2020-11-11
URML 2020-11-11
spurity 2020-11-10
yifangs 2020-10-13
Andrea0 2020-09-18
Ida 2020-09-16
ltd00 2020-09-12
tufeiax 2020-09-03
xjd0 2020-09-10
greatboylc 2020-09-10
adsadadaddadasda 2020-09-08
疯狂老司机 2020-09-08