修改MySQL端口后重启不了

Posted macupdate

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了修改MySQL端口后重启不了相关的知识,希望对你有一定的参考价值。

 

修改mysql端口为13306

vim /etc/my.cnf

[mysqld]
port=13306
lower_case_table_names=1

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

 

/etc/init.d/mysqld start
MySQL Daemon failed to start.
Starting mysqld:       [FAILED]

日志报错

180402 13:07:25 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
180402 13:13:19 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
180402 13:13:19 InnoDB: Initializing buffer pool, size = 8.0M
180402 13:13:19 InnoDB: Completed initialization of buffer pool
180402 13:13:19 InnoDB: Started; log sequence number 0 44233
180402 13:13:19 [ERROR] Can‘t start server: Bind on TCP/IP port: Permission denied
180402 13:13:19 [ERROR] Do you already have another mysqld server running on port: 13306 ?
180402 13:13:19 [ERROR] Aborting

180402 13:13:19 InnoDB: Starting shutdown...
180402 13:13:24 InnoDB: Shutdown completed; log sequence number 0 44233
180402 13:13:24 [Note] /usr/libexec/mysqld: Shutdown complete

1.解决办法

vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 13306 -j ACCEPT

 第一种方法是开放外网端口,第二种方式用于本地启动;

不写防火墙策略,无法远程访问数据库

2.关闭 SELinux问题

方法一: 不需要重启Linux:
 [[email protected] ~]# setenforce 0

 方法二:需要重启Linux:
vi /etc/selinux/config

SELINUX=disabled






















以上是关于修改MySQL端口后重启不了的主要内容,如果未能解决你的问题,请参考以下文章

mysql修改端口后启动失败

linux 重启后无法连接22端口

服务器重启MYSQL启动不了怎么办

修改centos7 ssh 登录端口

mysql修改默认端口方法

修改mysql端口后重启mysql报错:Can't start server: Bind on TCP/IP port. Got error...n denied