我从 16.04 升级到 18.04,mysql 安装失败。
我收到的错误是无法创建目录 /var/lib/mysql,如果我删除它,安装过程将重新创建该目录,然后给出无法创建的错误。我手动删除了所有 mysql 文件,并使用 apt-get 卸载,然后重试,错误相同:
The following NEW packages will be installed:
mysql-server
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/81.0 kB of archives.
After this operation, 91.1 kB of additional disk space will be used.
Selecting previously unselected package mysql-server.
(Reading database ... 283882 files and directories currently installed.)
Preparing to unpack .../mysql-server_8.0.13-1ubuntu18.04_amd64.deb ...
Unpacking mysql-server (8.0.13-1ubuntu18.04) ...
Setting up mysql-community-server (8.0.13-1ubuntu18.04) ...
mysqld: Can't create directory '/var/lib/mysql/' (OS errno 17 - File exists)
dpkg: error processing package mysql-community-server (--configure):
installed mysql-community-server package post-installation script subprocess returned error exit status 1
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-community-server (= 8.0.13-1ubuntu18.04); however:
Package mysql-community-server is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
mysql-community-server
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)
我似乎找不到解决办法。
编辑: ls -lah /var/lib/mysql 的输出
total 8.0K
drwxr-x--- 2 mysql mysql 4.0K Nov 11 16:01 .
drwxr-xr-x 70 root root 4.0K Nov 11 16:01 ..
编辑:清除 mysql-community-server 后我现在得到以下输出:
sudo apt-get install mysql-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libmecab2 mecab-ipadic mecab-ipadic-utf8 mecab-utils
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server-5.7 mysql-server-core-5.7
Suggested packages:
mailx tinyca
The following NEW packages will be installed:
mysql-client-5.7 mysql-client-core-5.7 mysql-common mysql-server mysql-server-5.7 mysql-server-core-5.7
0 upgraded, 6 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/20.3 MB of archives.
After this operation, 160 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Preconfiguring packages ...
Selecting previously unselected package mysql-common.
(Reading database ... 283582 files and directories currently installed.)
Preparing to unpack .../mysql-common_5.8+1.0.4_all.deb ...
Unpacking mysql-common (5.8+1.0.4) ...
Selecting previously unselected package mysql-client-core-5.7.
Preparing to unpack .../mysql-client-core-5.7_5.7.24-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-core-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-client-5.7.
Preparing to unpack .../mysql-client-5.7_5.7.24-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-client-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-server-core-5.7.
Preparing to unpack .../mysql-server-core-5.7_5.7.24-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-core-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Setting up mysql-common (5.8+1.0.4) ...
update-alternatives: using /etc/mysql/my.cnf.fallback to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Selecting previously unselected package mysql-server-5.7.
(Reading database ... 283738 files and directories currently installed.)
Preparing to unpack .../mysql-server-5.7_5.7.24-0ubuntu0.18.04.1_amd64.deb ...
Unpacking mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../mysql-server_5.7.24-0ubuntu0.18.04.1_all.deb ...
Unpacking mysql-server (5.7.24-0ubuntu0.18.04.1) ...
Processing triggers for ureadahead (0.100.0-20) ...
Setting up mysql-server-core-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Processing triggers for systemd (237-3ubuntu10.4) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Setting up mysql-client-core-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Setting up mysql-client-5.7 (5.7.24-0ubuntu0.18.04.1) ...
Setting up mysql-server-5.7 (5.7.24-0ubuntu0.18.04.1) ...
update-alternatives: using /etc/mysql/mysql.cnf to provide /etc/mysql/my.cnf (my.cnf) in auto mode
Renaming removed key_buffer and myisam-recover options (if present)
Specified filename /var/lib/mysql/ibdata1 does not exist.
2018-11-11T06:05:28.592183Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-11T06:05:28.592279Z 0 [Warning] Can't create test file /storage/mnt/var/lib/mysql/nibiru.lower-test
2018-11-11T06:05:28.592315Z 0 [Note] mysqld (mysqld 5.7.24-0ubuntu0.18.04.1) starting as process 24387 ...
2018-11-11T06:05:28.593679Z 0 [Warning] Can't create test file /var/lib/mysql/nibiru.lower-test
2018-11-11T06:05:28.593692Z 0 [Warning] Can't create test file /var/lib/mysql/nibiru.lower-test
2018-11-11T06:05:28.594276Z 0 [ERROR] Could not open file '/var/log/mysql/error.log' for error logging: Permission denied
2018-11-11T06:05:28.594290Z 0 [ERROR] Aborting
2018-11-11T06:05:28.594302Z 0 [Note] Binlog end
2018-11-11T06:05:28.594330Z 0 [Note] mysqld: Shutdown complete
Initialization of mysqld failed: 0
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 the control process exited with error code.
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: exit-code) since Sun 2018-11-11 19:05:29 NZDT; 3ms ago
Process: 24568 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 30973 (code=exited, status=1/FAILURE)
dpkg: error processing package mysql-server-5.7 (--configure):
installed mysql-server-5.7 package post-installation script subprocess returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.7; however:
Package mysql-server-5.7 is not configured yet.
dpkg: error processing package mysql-server (--configure):
dependency problems - leaving unconfigured
Processing triggers for systemd (237-3ubuntu10.4) ...
No apport report written because the error message indicates its a followup error from a previous failure.
Processing triggers for ureadahead (0.100.0-20) ...
Errors were encountered while processing:
mysql-server-5.7
mysql-server
E: Sub-process /usr/bin/dpkg returned an error code (1)