Linux 本地启动mysql对应的3306端口也启动的情况下无法远程连接
1.运行netstat -talnp命令行看3306是否打开netstat -talnp如返回中有tcp600 :::3306:::*LISTEN21498/mysqld则证明3306已开启。2.运行lsof -i:3306命令行查询3306是否被使用lsof -
1.运行netstat -talnp命令行看3306是否打开
netstat -talnp
如返回中有
tcp6 0 0 :::3306 :::* LISTEN 21498/mysqld
则证明3306已开启。
2.运行lsof -i:3306命令行查询3306是否被使用
lsof -i:3306
3.运行ps aux|grep mysql命令行看mysql是否在运行
ps aux|grep mysql
root 21353 0.0 0.1 9656 1560 pts/0 S 18:56 0:00 /bin/sh /opt/lampp/bin/mysqld_safe --datadir=/opt/lampp/var/mysql --pid-file=/opt/lampp/var/mysql/VM_42_114_centos.pid
mysql 21498 0.0 5.9 970100 60708 pts/0 Sl 18:56 0:00 /opt/lampp/sbin/mysqld --basedir=/opt/lampp --datadir=/opt/lampp/var/mysql --plugin-dir=/opt/lampp/lib/mysql/plugin/ --user=mysql --log-error=/opt/lam
pp/var/mysql/VM_42_114_centos.err --pid-file=/opt/lampp/var/mysql/VM_42_114_centos.pid --socket=/opt/lampp/var/mysql/mysql.sock --port=3306
root 23702 0.0 0.0 9032 672 pts/0 R+ 19:30 0:00 grep --color=auto mysql
即mysql服务在linux本地运行正常。
结论:mysql服务虽然在运行,可以在本地操作,但没有运行在3306端口。
此时修改mysql的配置文件如在xampp情况是在 ./lampp/etc my.cnf中
#Don’t listen on a TCP/IP port at all. This can be a security enhancement,
#if all processes that need to connect to mysqld run on the same host.
#All interaction with mysqld must be made via Unix sockets or named pipes.
#Note that using this option without enabling named pipes on Windows
#(via the “enable-named-pipe” option) will render mysqld useless!
将此段下面的参数skip-networking注释重启mysql服务,远程连接mysql正常。
#skip-networking
原因:参数skip-networking起的作用是:mysql不再在TCP / IP端口上进行监听,导致无法远程连接。
更多推荐
所有评论(0)