解决端口是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不知道

相关推荐
2501_933670792 分钟前
内部审计校招的数据化趋势:SQL、Excel、Power BI和证书选择
数据库·sql·excel
倔强的石头_17 分钟前
异构数据同步最难的不是“搬过去”:我如何理解 KFS 的全周期一致性校验
数据库
半兽先生1 小时前
MySQL + Milvus vs PostgreSQL + pgvector:AI 应用向量检索架构选型终极指南
mysql·postgresql·milvus
anxiao_m1 小时前
工业桌面云怎么选?从算力、适配、安全多维度实测对比
数据库·云桌面·云桌面厂家
qq_349447951 小时前
搭建mysql主从数据库
数据库·mysql
白帽黑客-晨哥1 小时前
Copilot 能换成本地吗?本地化 AI 编程助手完全指南
数据库·人工智能·copilot
l1t3 小时前
DeepSeek 4.1总结的Tom Lane 谈塑造 Postgres 三十年历程的架构决策
开发语言·数据库·postgresql·架构
星云API|微信接口开发4 小时前
企业微信二次开发实战笔记:如何用在线调试快速验证接口功能
数据库·笔记·企业微信
PHP实战开发录6 小时前
PHP事务异常后为什么数据还写进去了
mysql·php·开发
隔窗听雨眠10 小时前
记一次SQL Server数据库性能分析:从CPU100%到单配置修复的完整诊断
开发语言·数据库·php