我正在Ubuntu20.4上安装MySQL8.0,在安装之前我更新了apt。然后我使用以下命令:
sudo apt install mysql-server
上面写着";无法启动服务器":
Warning: Unable to start the server.
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.
invoke-rc.d: initscript mysql, action "start" failed.
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: signal) since Tue 2022-03-01 18:47:38 UTC; 119ms ago
Process: 46667 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 46685 ExecStart=/usr/sbin/mysqld (code=killed, signal=KILL)
Main PID: 46685 (code=killed, signal=KILL)
Status: "Server startup in progress"
dpkg: error processing package mysql-server-8.0 (--configure):
installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-8.0; however:
Package mysql-server-8.0 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for systemd (245.4-4ubuntu3.15) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.7) ...
Errors were encountered while processing:
mysql-server-8.0
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
MySQL已经安装,但我认为它并不成功。所以我试着启动服务器:
sudo service mysql start
它返回:
Job for mysql.service failed because a fatal signal was delivered to the control process.
See "systemctl status mysql.service" and "journalctl -xe" for details.
"systemctl状态mysql.service";显示:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: signal) since Tue 2022-03-01 19:00:36 UTC; 1min 52s ago
Process: 47280 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Process: 47288 ExecStart=/usr/sbin/mysqld (code=killed, signal=KILL)
Main PID: 47288 (code=killed, signal=KILL)
Status: "Server startup in progress"
Mar 01 19:00:35 ip-172-26-2-194 systemd[1]: mysql.service: Main process exited, code=killed, status=9/KILL
Mar 01 19:00:35 ip-172-26-2-194 systemd[1]: mysql.service: Failed with result 'signal'.
Mar 01 19:00:35 ip-172-26-2-194 systemd[1]: Failed to start MySQL Community Server.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: mysql.service: Scheduled restart job, restart counter is at 15.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: Stopped MySQL Community Server.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: mysql.service: Failed with result 'signal'.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: Failed to start MySQL Community Server.
"journalcl-xe";显示:
-- Automatic restarting of the unit mysql.service has been scheduled, as the result for
-- the configured Restart= setting for the unit.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: Stopped MySQL Community Server.
-- Subject: A stop job for unit mysql.service has finished
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A stop job for unit mysql.service has finished.
--
-- The job identifier is 33416 and the job result is done.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: mysql.service: Start request repeated too quickly.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: mysql.service: Failed with result 'signal'.
-- Subject: Unit failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- The unit mysql.service has entered the 'failed' state with result 'signal'.
Mar 01 19:00:36 ip-172-26-2-194 systemd[1]: Failed to start MySQL Community Server.
-- Subject: A start job for unit mysql.service has failed
-- Defined-By: systemd
-- Support: http://www.ubuntu.com/support
--
-- A start job for unit mysql.service has finished with a failure.
--
-- The job identifier is 33416 and the job result is failed.
Mar 01 19:03:07 ip-172-26-2-194 sshd[47296]: error: kex_exchange_identification: Connection closed by remote host
我真的不明白什么是";失败,结果为"信号";不知道下一步该怎么办。(我尝试过清除和重新安装,但不起作用(
这是一个亚马逊Lightsail云服务器,只有512MB的内存。我使用";免费的";命令,它显示176MB内存可用。
为了减少MySQL的内存消耗,一个非常小的my.cnf
文件可能看起来像这样:
[client]
port=3306
[mysql]
no-beep=
auto-rehash
[mysqld]
port=3306
datadir=D:/MySQL/Data
default-storage-engine=INNODB
report_port=3306
key_buffer_size=0M
tmp_table_size=1024
innodb_buffer_pool_size=5242880
innodb_log_buffer_size=262144
max_connections=5
sort_buffer_size=32768
read_buffer_size=8192
read_rnd_buffer_size=1
join_buffer_size=128
thread_stack=196K
binlog_cache_size=4096
当然,您至少应该更改datadir=
设置以指定数据的位置。
通过以上配置,可以启动MySQL 8.0.28(在Windows上测试(。
所以@James:更改my.cnf
中的设置,MySQL应该在"Amazon Lightsail云服务器";