![让Mysql监听所有端口Ubuntu 22.04](https://linux22.com/image/1073404/%E8%AE%A9Mysql%E7%9B%91%E5%90%AC%E6%89%80%E6%9C%89%E7%AB%AF%E5%8F%A3Ubuntu%2022.04.png)
我有这个代码:
[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb file per table
collation-server = utf8 general ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
这是针对较旧版本的 Ubuntu 的,现在我正在使用 Ubuntu 22.04,我正在尝试使其工作。我试图将其放在“/etc/mysql/conf.d”目录中,但我认为这不是此版本的 Ubuntu 中的位置。
我输入了代码,当我尝试重新启动服务时出现错误:
Job for mysql.service failed because the control process exited with error code.
See "systemctl status mysql.service" and "journalctl -xeu mysql.service" for details.
“systemctl status mysql.service”给出的错误是:
× mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2023-06-12 14:07:46 UTC; 6s ago
Process: 19824 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
CPU: 34ms
Jun 12 14:07:46 controller systemd[1]: Failed to start MySQL Community Server.
Jun 12 14:07:46 controller systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Jun 12 14:07:46 controller systemd[1]: Stopped MySQL Community Server.
Jun 12 14:07:46 controller systemd[1]: mysql.service: Start request repeated too quickly.
Jun 12 14:07:46 controller systemd[1]: mysql.service: Failed with result 'exit-code'.
Jun 12 14:07:46 controller systemd[1]: Failed to start MySQL Community Server.
你有什么建议吗?
答案1
我发现了错误是什么,实际上是上面代码中的拼写错误,而不是这样写:
[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb file per table
collation-server = utf8 general ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
我应该写:
[mysqld]
bind-address = 0.0.0.0
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8