phpstudy 为了安全起见,默认是只允许数据库本地连接的,但有时候我们需要远程连接,就需要如下修改:
/phpstudy/mysql/bin/mysql -uroot -p; # 登录mysql
输入密码进入。
使用grant all privileges on来更改用户对应某些库的远程权限
语法模板
grant all privileges on 库名.表名 to '用户名'@'IP地址' identified by '密码' with grant option;
例:
GRANT ALL PRIVILEGES ON *.* TO 'yonghuming'@'%' IDENTIFIED BY 'mima' WITH GRANT OPTION;
表示用户名为:yonghuming ,密码为:mima 的用户在所有的ip下接都可以远程连接这个数据库的所有库和表
exit
退出mysql数据库
sudo phpstudy restart # 重启phpstudy
重启使之生效