mysql - 在 Ubuntu 上安装 MySQL 8 时卡住

标签 mysql ubuntu

我在 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 内存可用。

最佳答案

最低限度my.cnf文件,以减少 MySQL 的内存消耗,可能如下所示:

[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 应该在你的
“亚马逊 Lightsail 云服务器”

关于mysql - 在 Ubuntu 上安装 MySQL 8 时卡住,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71313478/

相关文章:

php - 按时间对数据库行进行分类

用于复杂查询的 MySQL last_query_cost

linux - 我无法通过 apt-get 获取 "lxr "

ruby-on-rails - Resque 和 Redis 服务器不能很好地相互配合

Ubuntu 18.04 升级和 Cassandra 连接错误

windows - BASH:确定脚本是从虚拟机(Ubuntu)还是W10 bash应用程序调用的?

MySQL 用逗号等组合行值

php - 更新mysql php中的数据

python - 将 ubuntu 15.10 升级到 16.04 后 virtualenv python 崩溃了

phpMyAdmin 对于 php 5.5.8 出现错误 404