环境:

window10
phpstudy8.1.1.3
Vmware安装centos7.6

使用场景

window10安装mysql和redis
在Vmware安装centos7.6 桥接模式上网
centos7.6连接mysql和redis
mysql和redis开启远程登陆权限
在centos里访问物理机的ip地址

查看物理机ip地址

D:\phpstudy_pro\Extensions\MySQL5.7.26\bin>ipconfig
无线局域网适配器 WLAN:

   连接特定的 DNS 后缀 . . . . . . . :
   本地链接 IPv6 地址. . . . . . . . : fe80::b5d9:27af:ae4e:497f%10
   IPv4 地址 . . . . . . . . . . . . : 192.168.0.109
   子网掩码  . . . . . . . . . . . . : 255.255.255.0
   默认网关. . . . . . . . . . . . . : 192.168.0.1

软件下载

https://www.xp.cn/

开启mysql和redis

image

mysql设置密码:

image

设置mysql远程登陆权限

C:\Users\Administrator>d:
C:\Users\Administrator>cd D:\phpstudy_pro\Extensions\MySQL5.7.26\bin
D:\phpstudy_pro\Extensions\MySQL5.7.26\bin>mysql.exe -uroot -p123456
mysql> grant all privileges on *.* to root@"%" identified by "123456" with grant option;
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye

设置redis远程登陆权限

注释:bind 127.0.0.1

image

image

#bind 127.0.0.1
port 6379
timeout 65
maxclients 10000
databases 16
maxmemory 1048576000

尝试连接

linux系统里telnet一下试物理主机里的3306端口和6379端口试试

linux里安装telnet

[root@HmEduCentos01 ~]# yum install -y telnet

linux里连接mysql

[root@HmEduCentos01 ~]# telnet 192.168.0.109 3306
Trying 192.168.0.109...
Connected to 192.168.0.109.
Escape character is '^]'.
J
5.7.26
      140AsK�ys7'V"qC,5[mysql_native_passwordConnection closed by foreign host.

已经通了,输入 ctrl+] 再输入 quit 回车退出

linux连接redis

[root@HmEduCentos01 ~]# telnet 192.168.0.109 6379
Trying 192.168.0.109...
Connected to 192.168.0.109.
Escape character is '^]'.
已经通了,输入 ctrl+] 再输入 quit 回车退出