Mysql8 设置只有指定ip可以远程连接

1. 登录mysql8

mysql -uroot -p

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3280
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

2. 新建一个用户

use mysql;

CREATE USER 'username'@'你想远程连的服务ip' IDENTIFIED BY '连接密码';

3. 授权

grant all privileges on `revoluta-wechat.*` to 'revoluta'@'11.110.11.180';
如果报错就再执行1次
grant all privileges on `revoluta-wechat.*` to 'revoluta'@'11.110.11.180';

以上命令还是 会出现问题 用下边这个吧
grant all privileges on `*.*` to 'revoluta'@'11.110.11.180';

4. 更改加密方式

mysql8 修改了加密方式
ERROR 2059 (HY000): Authentication plugin 'caching_sha2_password' cannot be loaded:
更改
ALTER USER 'revoluta'@'59.110.221.180' IDENTIFIED WITH mysql_native_password BY '2019@Revoluta'

FLUSH PRIVILEGES;