云服务器MySQL开启远程连接

  • 来源:网络
  • 更新日期:2020-05-06

摘要:1.连接MySQL#mysql-uroot-proot2.登录mysql数据库MariaDB[(none)]>usemysql;3.更改远程连接设置MariaDB[mysql]>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%&#39

1.连接MySQL

#mysql-uroot-proot

2.登录mysql数据库

MariaDB[(none)]>usemysql;

3.更改远程连接设置

MariaDB[mysql]>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '1234567' WITH GRANT OPTION;

例如:指定访问demo数据库

MariaDB[mysql]>GRANT ALL PRIVILEGES ONdemo.* TO 'root'@'%' IDENTIFIED BY '1234567' WITH GRANT OPTION;

4.生效修改的权限

MariaDB[mysql]>flushprivileges;

5.查看修改结果

MariaDB[mysql]>selecthost,userfromuser;