1、关闭Linux上的防火墙(或者在Linux防火墙上添加允许通过的规则)
关闭防火墙:
[root@localhost ~]# systemctl stop firewalld
2、登录Linux上的MySQL创建数据库dkceshiyc
mysql> create database dkceshiyc;
3、开启远程登陆
mysql> use mysql;
mysql> update user set host='%'where user='root';
4、刷新权限(或者重启MySQL服务都可以)
mysql> flush privileges;
5、测试
打开Windows的cmd(必须在Windows上安装MySQL)
远程登录:
MySQL -uroot -p -h192.168.8.140
C:\Users\dell>mysql -uroot -p -h192.168.8.140
Enter password: ******
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 18
Server version: 8.0.26 MySQL Community Server - GPL
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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.
mysql>
查看当前数据库:show databases;
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| dkceshiyc |
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
5 rows in set (0.00 sec)
登陆成功!!!