企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
#### Linux系统开启MySQL远程连接 * * * * * 1. 连接数据库 ~~~ [root@izbp192gcqz9hrnj21lewuz ~]# mysql -uroot -pguFLVNJKJa -h127.0.0.1 Warning: Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.36 Source distribution Copyright (c) 2000, 2017, 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. mysql> ~~~ 2. 创建数据库 ~~~ mysql> SHOW DATABASES; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | +--------------------+ 3 rows in set (0.08 sec) mysql> CREATE DATABASE champion; Query OK, 1 row affected (0.02 sec) ~~~ 3. 授权远程登录数据库 ~~~ mysql> grant all privileges on champion.* to 'root'@'%' identified by 'guFLVNJKJa'; Query OK, 0 rows affected (0.05 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) ~~~ 2. 在服务器端开启远程访问 首先进入mysql数据库,然后输入下面两个命令: ~~~ grant all privileges on *.* to 'root'@'%' identified by 'password'; flush privileges; ~~~ * 第一个`*`是数据库,可以改成允许访问的数据库名称。 * 第二个 是数据库的表名称,代表允许访问任意的表。 * `root`代表远程登录使用的用户名,可以自定义。 * `%`代表允许任意ip登录,如果你想指定特定的IP,可以把%替换掉就可以了 * `password`代表远程登录时使用的密码,可以自定义 * `flush privileges;`是让权限立即生效 ~~~ grant all privileges on champion.* to 'root'@'%' identified by 'guFLVNJKJa'; flush privileges; ~~~