1. MySQL用户授权和修改密码
- 查看已有用户的权限信息
mysql> select user,host,plugin from mysql.user;
+------------------+-----------+-----------------------+
| user | host | plugin |
+------------------+-----------+-----------------------+
| root | % | caching_sha2_password |
| mysql.infoschema | localhost | mysql_native_password |
| mysql.session | localhost | mysql_native_password |
| mysql.sys | localhost | mysql_native_password |
| root | localhost | caching_sha2_password |
+------------------+-----------+-----------------------+
5 rows in set (0.00 sec)
- MySQL 8.0 的用户授权语句和之前版本不同,老版本的常用授权语句,在 MySQL 8.0 版本中 已不能使用,如使用旧版本授权语句会报错。
mysql> GRANT ALL PRIVILEGES ON *.* TO `mike`@`%` IDENTIFIED BY '000000' WITH GRANT OPTION;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IDENTIFIED BY '000000' WITH GRANT OPTION' at line 1
- 在 MySQL 8.0 版本中正确授权语句
mysql> CREATE USER 'mike'@'%' IDENTIFIED BY '000000';
mysql> GRANT ALL ON *.* TO 'mike'@'%' WITH GRANT OPTION;
更多参见:这里
2. Windows防火墙开放3306端口
Windows防火墙------高级设置------入站规则------新建规则------TCP,指定端口3306------一路默认到底。