Windows安装mysql后怎么开启root的网络访问权限
Windows安装MySQL后默认只能本机访问,怎么开启网络访问
mysql> create user 'root'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on *.* to 'root'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
配置MySQL,让MySQL支持被外网访问
设置权限首先要找到MySQL的bin目录,默认在C:\Program Files\MySQL\MySQL Server 8.0\bin
然后我们Win+R输入cmd打开控制台,使用cd命令到MySQL的bin目录下,执行以下操作:
1.登录数据库,然后输入密码
mysql -u root -p
2.然后打开mysql
mysql> use mysql;
3.查询host
mysql> select user,host from user;
4.创建host
mysql> update user set host='%' where user='root';
mysql> flush privileges;
5.授权用户
(1)MySQL 8.0以前版本
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'mypwd' WITH GRANT OPTION;
mysql> flush privileges;
(2)MySQL 8.0及之后版本 (如果host列表中已有root和%用户,则可以不执行CREATE语句)
mysql> CREATE USER 'root'@'%' IDENTIFIED BY '123456';
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
mysql> flush privileges;
以上就是mysql如何让外网访问的详细内容
到此这篇关于Windows安装MySQL后怎么开启root的网络访问权限的文章就介绍到这了,更多相关Windows安装MySQL内容请搜索编程客栈(www.cppcns.com)以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程客栈(www.cppcns.com)!