![无法安装 MySQL](https://linux22.com/image/1025826/%E6%97%A0%E6%B3%95%E5%AE%89%E8%A3%85%20MySQL.png)
我是 Ubuntu 的新手。我甚至不知道要运行任何命令。我尝试安装 MySQL,但总是出现错误。
我运行了这个命令:
sudo apt-get install mysql-community-client-plugins
我得到了这个:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
mysql-community-client-plugins is already the newest version (8.0.28-1ubuntu20.04).
The following packages were automatically installed and are no longer required:
galera-4 libconfig-inifiles-perl libdbi-perl mariadb-client-10.5 mariadb-server-core-10.5 socat
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
9 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Setting up libconfig-inifiles-perl (3.000003-1) ...
Setting up galera-4 (26.4.9-1) ...
Setting up mariadb-common (1:10.5.13-0ubuntu0.21.10.1) ...
update-alternatives: error: alternative path /etc/mysql/mariadb.cnf doesn't exist
dpkg: error processing package mariadb-common (--configure):
installed mariadb-common package post-installation script subprocess returned error exit status 2
Setting up socat (1.7.4.1-3ubuntu1) ...
dpkg: dependency problems prevent configuration of mariadb-client-core-10.5:
mariadb-client-core-10.5 depends on mariadb-common (>= 1:10.5.13-0ubuntu0.21.10.1); however:
Package mariadb-common is not configured yet.
dpkg: error processing package mariadb-client-core-10.5 (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
No apport report written because the error message indicates its a followup error from a previous failure.
dpkg: dependency problems prevent configuration of libmariadb3:amd64:
libmariadb3:amd64 depends on mariadb-common; however:
Package mariadb-common is not configured yet.
dpkg: error processing package libmariadb3:amd64 (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of mariadb-client-10.5:
mariadb-client-10.5 depends on mariadb-client-core-10.5 (>= 1:10.5.13-0ubuntu0.21.10.1); however:
Package mariadb-client-core-10.5 is not configured yet.
dpkg: error processing package mariadb-client-10.5 (--configure):
dependency problems - leaving unconfigured
Setting up libdbi-perl:amd64 (1.643-3build2) ...
No apport report written because MaxReports is reached already
dpkg: dependency problems prevent configuration of mariadb-server-core-10.5:
mariadb-server-core-10.5 depends on mariadb-common (>= 1:10.5.13-0ubuntu0.21.10.1); however:
Package mariadb-common is not configured yet.
dpkg: error processing package mariadb-server-core-10.5 (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already
Processing triggers for man-db (2.9.4-2) ...
Errors were encountered while processing:
mariadb-common
mariadb-client-core-10.5
libmariadb3:amd64
mariadb-client-10.5
mariadb-server-core-10.5
E: Sub-process /usr/bin/dpkg returned an error code (1)
我不知道下一步该怎么做。请帮忙。
命令:
sudo apt install mysql-server
输出:
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
galera-4 libconfig-inifiles-perl libdbi-perl libmariadb3 socat
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmecab2
libprotobuf-lite23 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-server-8.0 mysql-server-core-8.0
Suggested packages:
libipc-sharedcache-perl mailx tinyca
The following packages will be REMOVED:
mariadb-client-10.5 mariadb-client-core-10.5 mariadb-server-core-10.5
The following NEW packages will be installed:
libcgi-fast-perl libcgi-pm-perl libevent-core-2.1-7 libevent-pthreads-2.1-7 libfcgi-bin libfcgi-perl libfcgi0ldbl libhtml-template-perl libmecab2
libprotobuf-lite23 mecab-ipadic mecab-ipadic-utf8 mecab-utils mysql-client-8.0 mysql-client-core-8.0 mysql-server mysql-server-8.0
mysql-server-core-8.0
0 upgraded, 18 newly installed, 3 to remove and 0 not upgraded.
5 not fully installed or removed.
Need to get 21.1 MB/28.6 MB of archives.
After this operation, 193 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu impish-updates/main amd64 mysql-client-core-8.0 amd64 8.0.28-0ubuntu0.21.10.3 [2,734 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu impish-updates/main amd64 mysql-client-8.0 amd64 8.0.28-0ubuntu0.21.10.3 [22.7 kB]
Get:3 http://in.archive.ubuntu.com/ubuntu impish-updates/main amd64 mysql-server-core-8.0 amd64 8.0.28-0ubuntu0.21.10.3 [16.9 MB]
Get:4 http://in.archive.ubuntu.com/ubuntu impish-updates/main amd64 mysql-server-8.0 amd64 8.0.28-0ubuntu0.21.10.3 [1,384 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu impish-updates/main amd64 mysql-server all 8.0.28-0ubuntu0.21.10.3 [9,534 B]
Fetched 21.1 MB in 6s (3,562 kB/s)
Preconfiguring packages ...
dpkg: warning: files list file for package 'mysql-community-client-plugins' missing; assuming package has no files currently installed
(Reading database ... 212677 files and directories currently installed.)
Removing mariadb-client-10.5 (1:10.5.13-0ubuntu0.21.10.1) ...
Removing mariadb-client-core-10.5 (1:10.5.13-0ubuntu0.21.10.1) ...
Removing mariadb-server-core-10.5 (1:10.5.13-0ubuntu0.21.10.1) ...
Selecting previously unselected package mysql-client-core-8.0.
dpkg: warning: files list file for package 'mysql-community-client-plugins' missing; assuming package has no files currently installed
(Reading database ... 212490 files and directories currently installed.)
Preparing to unpack .../00-mysql-client-core-8.0_8.0.28-0ubuntu0.21.10.3_amd64.deb ...
Unpacking mysql-client-core-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Selecting previously unselected package mysql-client-8.0.
Preparing to unpack .../01-mysql-client-8.0_8.0.28-0ubuntu0.21.10.3_amd64.deb ...
Unpacking mysql-client-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Selecting previously unselected package libevent-core-2.1-7:amd64.
Preparing to unpack .../02-libevent-core-2.1-7_2.1.12-stable-1_amd64.deb ...
Unpacking libevent-core-2.1-7:amd64 (2.1.12-stable-1) ...
Selecting previously unselected package libevent-pthreads-2.1-7:amd64.
Preparing to unpack .../03-libevent-pthreads-2.1-7_2.1.12-stable-1_amd64.deb ...
Unpacking libevent-pthreads-2.1-7:amd64 (2.1.12-stable-1) ...
Selecting previously unselected package libmecab2:amd64.
Preparing to unpack .../04-libmecab2_0.996-14build4_amd64.deb ...
Unpacking libmecab2:amd64 (0.996-14build4) ...
Selecting previously unselected package libprotobuf-lite23:amd64.
Preparing to unpack .../05-libprotobuf-lite23_3.12.4-1ubuntu3_amd64.deb ...
Unpacking libprotobuf-lite23:amd64 (3.12.4-1ubuntu3) ...
Selecting previously unselected package mysql-server-core-8.0.
Preparing to unpack .../06-mysql-server-core-8.0_8.0.28-0ubuntu0.21.10.3_amd64.deb ...
Unpacking mysql-server-core-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Selecting previously unselected package mysql-server-8.0.
Preparing to unpack .../07-mysql-server-8.0_8.0.28-0ubuntu0.21.10.3_amd64.deb ...
Unpacking mysql-server-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Selecting previously unselected package libcgi-pm-perl.
Preparing to unpack .../08-libcgi-pm-perl_4.51-1_all.deb ...
Unpacking libcgi-pm-perl (4.51-1) ...
Selecting previously unselected package libfcgi0ldbl:amd64.
Preparing to unpack .../09-libfcgi0ldbl_2.4.2-2build1_amd64.deb ...
Unpacking libfcgi0ldbl:amd64 (2.4.2-2build1) ...
Selecting previously unselected package libfcgi-perl:amd64.
Preparing to unpack .../10-libfcgi-perl_0.79+ds-2build1_amd64.deb ...
Unpacking libfcgi-perl:amd64 (0.79+ds-2build1) ...
Selecting previously unselected package libcgi-fast-perl.
Preparing to unpack .../11-libcgi-fast-perl_1%3a2.15-1_all.deb ...
Unpacking libcgi-fast-perl (1:2.15-1) ...
Selecting previously unselected package libfcgi-bin.
Preparing to unpack .../12-libfcgi-bin_2.4.2-2build1_amd64.deb ...
Unpacking libfcgi-bin (2.4.2-2build1) ...
Selecting previously unselected package libhtml-template-perl.
Preparing to unpack .../13-libhtml-template-perl_2.97-1.1_all.deb ...
Unpacking libhtml-template-perl (2.97-1.1) ...
Selecting previously unselected package mecab-utils.
Preparing to unpack .../14-mecab-utils_0.996-14build4_amd64.deb ...
Unpacking mecab-utils (0.996-14build4) ...
Selecting previously unselected package mecab-ipadic.
Preparing to unpack .../15-mecab-ipadic_2.7.0-20070801+main-3_all.deb ...
Unpacking mecab-ipadic (2.7.0-20070801+main-3) ...
Selecting previously unselected package mecab-ipadic-utf8.
Preparing to unpack .../16-mecab-ipadic-utf8_2.7.0-20070801+main-3_all.deb ...
Unpacking mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
Selecting previously unselected package mysql-server.
Preparing to unpack .../17-mysql-server_8.0.28-0ubuntu0.21.10.3_all.deb ...
Unpacking mysql-server (8.0.28-0ubuntu0.21.10.3) ...
Setting up libmecab2:amd64 (0.996-14build4) ...
Setting up mysql-client-core-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Setting up libfcgi0ldbl:amd64 (2.4.2-2build1) ...
Setting up libcgi-pm-perl (4.51-1) ...
Setting up libfcgi-bin (2.4.2-2build1) ...
Setting up libhtml-template-perl (2.97-1.1) ...
Setting up mariadb-common (1:10.5.13-0ubuntu0.21.10.1) ...
update-alternatives: error: alternative path /etc/mysql/mariadb.cnf doesn't exist
dpkg: error processing package mariadb-common (--configure):
installed mariadb-common package post-installation script subprocess returned error exit status 2
Setting up libprotobuf-lite23:amd64 (3.12.4-1ubuntu3) ...
Setting up mecab-utils (0.996-14build4) ...
Setting up libevent-core-2.1-7:amd64 (2.1.12-stable-1) ...
dpkg: dependency problems prevent configuration of libmariadb3:amd64:
libmariadb3:amd64 depends on mariadb-common; however:
Package mariadb-common is not configured yet.
dpkg: error processing package libmariadb3:amd64 (--configure):
dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
Setting up mysql-client-8.0 (8.0.28-0ubuntu0
.21.10.3) ...
Setting up libfcgi-perl:amd64 (0.79+ds-2build1) ...
Setting up libevent-pthreads-2.1-7:amd64 (2.1.12-stable-1) ...
Setting up mecab-ipadic (2.7.0-20070801+main-3) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up libcgi-fast-perl (1:2.15-1) ...
Setting up mysql-server-core-8.0 (8.0.28-0ubuntu0.21.10.3) ...
Setting up mecab-ipadic-utf8 (2.7.0-20070801+main-3) ...
Compiling IPA dictionary for Mecab. This takes long time...
reading /usr/share/mecab/dic/ipadic/unk.def ... 40
emitting double-array: 100% |###########################################|
/usr/share/mecab/dic/ipadic/model.def is not found. skipped.
reading /usr/share/mecab/dic/ipadic/Conjunction.csv ... 171
reading /usr/share/mecab/dic/ipadic/Noun.demonst.csv ... 120
reading /usr/share/mecab/dic/ipadic/Interjection.csv ... 252
reading /usr/share/mecab/dic/ipadic/Postp-col.csv ... 91
reading /usr/share/mecab/dic/ipadic/Symbol.csv ... 208
reading /usr/share/mecab/dic/ipadic/Auxil.csv ... 199
reading /usr/share/mecab/dic/ipadic/Prefix.csv ... 221
reading /usr/share/mecab/dic/ipadic/Noun.verbal.csv ... 12146
reading /usr/share/mecab/dic/ipadic/Noun.nai.csv ... 42
reading /usr/share/mecab/dic/ipadic/Adverb.csv ... 3032
reading /usr/share/mecab/dic/ipadic/Noun.number.csv ... 42
reading /usr/share/mecab/dic/ipadic/Others.csv ... 2
reading /usr/share/mecab/dic/ipadic/Noun.place.csv ... 72999
reading /usr/share/mecab/dic/ipadic/Adnominal.csv ... 135
reading /usr/share/mecab/dic/ipadic/Noun.proper.csv ... 27328
reading /usr/share/mecab/dic/ipadic/Noun.adjv.csv ... 3328
reading /usr/share/mecab/dic/ipadic/Noun.others.csv ... 151
reading /usr/share/mecab/dic/ipadic/Noun.org.csv ... 16668
reading /usr/share/mecab/dic/ipadic/Verb.csv ... 130750
reading /usr/share/mecab/dic/ipadic/Noun.name.csv ... 34202
reading /usr/share/mecab/dic/ipadic/Filler.csv ... 19
reading /usr/share/mecab/dic/ipadic/Suffix.csv ... 1393
reading /usr/share/mecab/dic/ipadic/Postp.csv ... 146
reading /usr/share/mecab/dic/ipadic/Noun.adverbal.csv ... 795
reading /usr/share/mecab/dic/ipadic/Noun.csv ... 60477
reading /usr/share/mecab/dic/ipadic/Adj.csv ... 27210
emitting double-array: 100% |###########################################|
reading /usr/share/mecab/dic/ipadic/matrix.def ... 1316x1316
emitting matrix : 100% |###########################################|
done!
update-alternatives: using /var/lib/mecab/dic/ipadic-utf8 to provide /var/lib/mecab/dic/debian (mecab-dictionary) in auto mode
Setting up mysql-server-8.0 (8.0.28-0ubuntu0.21.10.3) ...
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)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 25836
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in profile /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Created symlink /etc/systemd/system/multi-user.target.wants/mysql.service → /lib/systemd/system/mysql.service.
Setting up mysql-server (8.0.28-0ubuntu0.21.10.3) ...
Processing triggers for man-db (2.9.4-2) ...
Processing triggers for libc-bin (2.34-0ubuntu3) ...
Errors were encountered while processing:
mariadb-common
libmariadb3:amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
答案1
清除所有 MySQL 包:
sudo apt purge mysql-server mysql-client mysql-common mysql-server-core-* mysql-client-core-*
删除所有 MySQL 文件:
sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql
清除所有不需要的包:
sudo apt autoremove
sudo apt autoclean
重新安装 Mysql
sudo apt install mysql-server
sudo mysql_secure_installation