mysql> show global variables like 'port'; 是0
打开目录
/etc/mysql/mysql.conf.d
修改这段话为
[mysqld]
#
# * Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
datadir = /var/lib/mysql
#skip-grant-tables
# If MySQL is running as a replication slave, this should be
# changed. Ref https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_tmpdir
# tmpdir = /tmp
#
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
bind-address = 127.0.0.1
mysqlx-bind-address = 127.0.0.1
其中skip-grant-tables 这个应该是免密码登录,给注释掉,我也不知道为什么跟端口0相关
然后重启数据库
systemctl restart mysql
然后
登录数据库
mysql -uroot -p 123456 1234456是我的密码
然后查看
netstat -lanp | grep 3306
tcp 0 0 127.0.0.1:33060 0.0.0.0:* LISTEN 122309/mysqld
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 122309/mysqld 文章来源:https://www.toymoban.com/news/detail-856824.html
启动成功 为什么还有个33060不知道文章来源地址https://www.toymoban.com/news/detail-856824.html
到了这里,关于解决端口是0问题,解决mysql无法看到3306端口监听的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!