解决端口是0问题,解决mysql无法看到3306端口监听

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

启动成功 为什么还有个33060不知道

相关推荐
随逸1772 小时前
《Milvus向量数据库从入门到实战,手把手搭建语义检索系统》
数据库
神秘的猪头3 小时前
🚀 React 开发者进阶:RAG 核心——手把手带你玩转 Milvus 向量数据库
数据库·后端·llm
0xDevNull20 小时前
MySQL索引进阶用法
后端·mysql
0xDevNull20 小时前
MySQL索引用法
mysql
IvorySQL21 小时前
PostgreSQL 技术日报 (3月6日)|为什么 Ctrl-C 在 psql 里让人不安?
数据库·postgresql·开源
NineData1 天前
数据库管理工具NineData,一年进化成为数万+开发者的首选数据库工具?
运维·数据结构·数据库
程序员小崔日记1 天前
一篇文章彻底搞懂 MySQL 和 Redis:原理、区别、项目用法全解析(建议收藏)
redis·mysql·项目实战
IvorySQL1 天前
PostgreSQL 技术日报 (3月5日)|规划器控制力升级,内核能力再进阶
数据库·postgresql·开源
武子康1 天前
大数据-241 离线数仓 - 实战:电商核心交易数据模型与 MySQL 源表设计(订单/商品/品类/店铺/支付)
大数据·后端·mysql