我在 Ubuntu20.04 上安裝 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 status 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.
“journalctl -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
我不太明白什么是“結果‘信號’失敗”,也不知道下一步該做什么。(我試過清除并重新安裝,它不起作用)
它是一個 Amazon Lightsail 云服務器,只有 512MB 記憶體。我使用“free”命令,它顯示有 176MB 記憶體可用。
uj5u.com熱心網友回復:
為了減少 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 云服務器”上啟動
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/436273.html
上一篇:沒有為命令設定版本
