1.进入虚拟机mysql
[root@localhost ~]# mysql -u root -p2.进入mysql 目录 并查看mysql目录是否是本地查看mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select 'host' from user where user='root';
+------+
| host |
+------+
| host |
+------+
1 row in set (0.24 sec)3.host则为本地可以访问,接下来我们改为外网访问
mysql> update user set host='%' where user='root';
Query OK, 1 row affected (2.41 sec)
Rows matched: 1 Changed: 1 Warnings: 0
4.退出mysql,重启服务
mysql> exit;
Bye
[root@localhost ~]# service mysqld stop;
Shutting down MySQL............................. SUCCESS!
[root@localhost ~]# service mysql start;
Redirecting to /bin/systemctl start mysql.service
5.启动成功后,本地mysql连接虚拟机,OK!
本文介绍如何将MySQL数据库从仅允许本地连接配置为支持远程访问。通过更改MySQL中root用户的host参数,使其支持‘%’通配符,实现从任意IP地址进行连接。文章详细展示了操作步骤,包括使用命令行进入MySQL、更新用户表中的host字段、重启MySQL服务等。
2097

被折叠的 条评论
为什么被折叠?



