我已使用以下命令在 Oracle Linux 7 上安装了 mysql-community-server 8.0官方文档
已经安装成功了,但是:
# service mysqld start
结果是:
Redirecting to /bin/systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@myhost tmp]# journalctl -xe
Oct 02 16:19:29 myhost systemd[1]: Starting MySQL Server...
-- Subject: Unit mysqld.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has begun starting up.
Oct 02 16:19:39 myhost systemd[1]: mysqld.service: main process exited, code=exited, status=1/FAILURE
Oct 02 16:19:39 myhost systemd[1]: Failed to start MySQL Server.
-- Subject: Unit mysqld.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit mysqld.service has failed.
--
-- The result is failed.
Oct 02 16:19:39 myhost systemd[1]: Unit mysqld.service entered failed state.
Oct 02 16:19:39 myhost systemd[1]: mysqld.service failed.
[root@myhost tmp]# vi /var/log/mysqld.log
2019-10-02T13:19:36.151426Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.17) starting as process 21346
2019-10-02T13:19:38.162471Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2019-10-02T13:19:38.165671Z 0 [ERROR] [MY-010262] [Server] Can't start server: Bind on TCP/IP port: Address already in use
2019-10-02T13:19:38.165697Z 0 [ERROR] [MY-010257] [Server] Do you already have another mysqld server running on port: 3306 ?
2019-10-02T13:19:38.166475Z 0 [ERROR] [MY-010119] [Server] Aborting
2019-10-02T13:19:38.958654Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.17) MySQL Community Server - GPL.
[root@myhost tmp]# ps aux | grep mysql
root 2031 0.0 0.0 115388 3108 ? S 11:59 0:00 /bin/sh /opt/zbox/run/mysql/mysqld_safe --defaults-file=/opt/zbox/etc/mysql/my.cnf
nobody 2487 0.0 0.4 525380 36448 ? Sl 11:59 0:00 /opt/zbox/run/mysql/mysqld --defaults-file=/opt/zbox/etc/mysql/my.cnf --basedir=/opt/zbox/run/mysql --datadir=/opt/zbox/data/mysql --plugin-dir=/opt/zbox/run/lib/mysql/plugin --user=nobody --log-error=/opt/zbox/logs/mysql_error.log --pid-file=/opt/zbox/tmp/mysql/mysqld.pid --socket=/opt/zbox/tmp/mysql/mysql.sock --port=3306
我发现 mysql-community-server 的配置文件位于路径:/etc/my.cnf
。但它不包含有关端口设置的信息。/etc/my.cnf.d/
文件夹是空的。
我怎样才能改变它的端口?
答案1
https://dev.mysql.com/doc/refman/8.0/en/using-systemd.html#systemd-multiple-mysql-instances表明该端口可能未在 systemd 单元中指定,my.cnf
但已在mysqld.service
systemd 单元中指定。
找到该mysqld.service
文件(尝试/lib/systemd/system/
或/etc/systemd/system/
)并按照文档中的说明更改该文件内的端口。