MariaDB 10.3 是否与 MySQL 8.0.20 兼容,依赖性检查失败

MariaDB 10.3 是否与 MySQL 8.0.20 兼容,依赖性检查失败

我已经安装了 Ubuntu 20.04,并应用了 Devstack 作为 Openstack 应用程序

mysql 正在运行:

stack@rafael-VirtualBox:~/devstack$ mysql --version
mysql  Ver 8.0.20-0ubuntu0.20.04.1 for Linux on x86_64 ((Ubuntu))
stack@rafael-VirtualBox:~/devstack$ mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 68
Server version: 8.0.20-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
root@rafael-VirtualBox:~# systemctl status mysql

mysql.service - MySQL Community Server

     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)

     Active: active (running) since Tue 2020-06-02 15:09:08 CDT; 2 days ago
    Process: 986 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
   Main PID: 1086 (mysqld)
     Status: "Server is operational"
      Tasks: 61 (limit: 4616)
     Memory: 325.4M
     CGroup: /system.slice/mysql.service
             └─1086 /usr/sbin/mysqld


Jun 02 15:08:41 rafael-VirtualBox systemd[1]: Starting MySQL Community Server...
Jun 02 15:09:08 rafael-VirtualBox systemd[1]: Started MySQL Community Server.

当我尝试安装 MariaDB 时:

sudo apt update
sudo apt install mariadb-server
sudo mysql_secure_installation

我收到以下信息:

root@rafael-VirtualBox:~# sudo apt update
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease         
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease            
Reading package lists... Done
Building dependency tree       
Reading state information... Done
45 packages can be upgraded. Run 'apt list --upgradable' to see them.
root@rafael-VirtualBox:~# sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 **mariadb-server : Depends: mariadb-server-10.3 (>= 1:10.3.22-1ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.**

所以这个错误让我很困惑......为什么它不能自动安装???

The following packages have unmet dependencies:
mariadb-server : Depends: mariadb-server-10.3 (>= 1:10.3.22-1ubuntu1) but it is not going to be installed

E: Unable to correct problems, you have held broken packages.

似乎改变命令就起了作用:

sudo apt install mariadb-server-10.3
sudo apt install mariadb-server
root@rafael-VirtualBox:/var/log# sudo mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Enter current password for root (enter for none): 
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
Enter current password for root (enter for none):

那么我该如何解决错误 2002,网上的信息和 YouTube 视频都没有 Ubuntu 20.4 和 MariaDb 10.3


更新:

我进行了编辑/etc/mysql/my.cnf/etc/mysql/cnf解决了这个问题,但又遇到了另一个问题......

#cat > /etc/mysql/my.cnf << EOF
#cat > /etc/mysql/mariadb.cnf << EOF

# This will be passed to all mysql clients
# It has been reported that passwords should be enclosed with ticks/quotes
# escpecially if they contain "#" chars...
# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
[client]
port        = 3306
socket      = /var/run/mysqld/mysqld.sock

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
max_connections = 1024
#default-storage-engine = InnoDB
#sql_mode = TRADITIONAL
#bind-address = 0.0.0.0
#lower_case_table_names = 2
user        = mysql
pid-file    = /var/run/mysqld/mysqld.pid
socket      = /var/run/mysqld/mysqld.sock
port        = 3306
basedir     = /usr/bin
datadir     = /var/lib/mysql
tmpdir      = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking

innodb_buffer_pool_size = 10M
innodb_log_file_size = 1000M

character_set_server           = utf8mb4                             # For modern applications, default in MySQL 8.0
thread_cache_size              = 151                                 # Up to max_connections makes sense


[mysqld_safe]
socket      = /var/run/mysqld/mysqld.sock
nice        = 0

下一期:

Jun  4 20:55:21 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:21 0 [ERROR] InnoDB: Invalid flags 0x4800 in ./ibdata1
Jun  4 20:55:21 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:21 0 [ERROR] InnoDB: Plugin initialization aborted with error Data structure corruption
Jun  4 20:55:22 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:22 0 [Note] InnoDB: Starting shutdown...
Jun  4 20:55:22 rafael-VirtualBox kernel: [ 6034.871865] audit: type=1400 audit(1591322122.402:15641): apparmor="DENIED" operation="sendmsg" info="Failed name lookup - disconnect
ed path" error=-13 profile="/usr/sbin/mysqld" name="run/systemd/notify" pid=76969 comm="mysqld" requested_mask="w" denied_mask="w" fsuid=132 ouid=0
Jun  4 20:55:22 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:22 0 [ERROR] Plugin 'InnoDB' init function returned error.
Jun  4 20:55:22 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:22 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Jun  4 20:55:22 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:22 0 [Note] Plugin 'FEEDBACK' is disabled.
Jun  4 20:55:22 rafael-VirtualBox mysqld[76969]: 2020-06-04 20:55:22 0 [ERROR] Could not open mysql.plugin table. Some plugins may be not loaded

然后必须清除系统表:

systemctl stop mariadb
rm -R /var/lib/mysql/*
mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

重新启动了 Mariadb 服务,没有错误,但卡在激活状态:

root@rafael-VirtualBox:/opt/stack# systemctl start mariadb

root@rafael-VirtualBox:/var/lib/mysql# systemctl status mariadb
● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: activating (start) since Thu 2020-06-04 21:20:03 CDT; 9s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 78228 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 78235 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 78237 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_STAR>
   Main PID: 78300 (mysqld)
      Tasks: 30 (limit: 4616)
     Memory: 55.2M
     CGroup: /system.slice/mariadb.service
             └─78300 /usr/sbin/mysqld

Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] InnoDB: Waiting for purge to start
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] InnoDB: 10.3.22 started; log sequence number 1625457; transaction id 21
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] Plugin 'FEEDBACK' is disabled.
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] InnoDB: Buffer pool(s) load completed at 200604 21:20:03
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] Server socket created on IP: '::'.
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] Reading of all Master_info entries succeeded
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] Added new Master_info '' to hash table
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: 2020-06-04 21:20:03 0 [Note] /usr/sbin/mysqld: ready for connections.
Jun 04 21:20:03 rafael-VirtualBox mysqld[78300]: Version: '10.3.22-MariaDB-1ubuntu1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Ubuntu 20.04
lines 1-24/24 (END)

到:

Job for mariadb.service failed because a timeout was exceeded.
See "systemctl status mariadb.service" and "journalctl -xe" for details.
root@rafael-VirtualBox:/opt/stack# systemctl status mariadb.service
● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: failed (Result: timeout) since Thu 2020-06-04 21:14:44 CDT; 1min 24s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 77248 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 77256 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 77261 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemc>
    Process: 77318 ExecStart=/usr/sbin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=0/SUCCESS)
   Main PID: 77318 (code=exited, status=0/SUCCESS)

Jun 04 21:14:43 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:43 0 [Note] Event Scheduler: Purging the queue. 0 events
Jun 04 21:14:43 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:43 0 [Note] InnoDB: Starting shutdown...
Jun 04 21:14:43 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:43 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
Jun 04 21:14:43 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:43 0 [Note] InnoDB: Instance 0, restricted to 160 pages due to innodb_buf_pool_du>
Jun 04 21:14:43 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:43 0 [Note] InnoDB: Buffer pool(s) dump completed at 200604 21:14:43
Jun 04 21:14:44 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:44 0 [Note] InnoDB: Shutdown completed; log sequence number 1625457; transaction >
Jun 04 21:14:44 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:44 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
Jun 04 21:14:44 rafael-VirtualBox mysqld[77318]: 2020-06-04 21:14:44 0 [Note] /usr/sbin/mysqld: Shutdown complete
Jun 04 21:14:44 rafael-VirtualBox systemd[1]: mariadb.service: Failed with result 'timeout'.
Jun 04 21:14:44 rafael-VirtualBox systemd[1]: Failed to start MariaDB 10.3.22 database server.

我会接受建议继续调查


更新


好像安装 Mariadb 时出现错误

如果你被这个错误,错误报告中给出了解决方案的建议:

  1. echo "/usr/sbin/mysqld { }" > /etc/apparmor.d/usr.sbin.mysqld
  2. apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
  3. systemctl restart mariadb

背景

如果您之前安装了 MySQL,它会激活与 MariaDB 不兼容的 AppArmor 配置文件。 apt-get remove --purge仅删除配置文件,但不会停用/卸载它。只有手动卸载它才能让 MariaDB 不受 AppArmor 的阻碍。

我的输出已更改为ACTIVE:

root@rafael-VirtualBox:/var/lib/mysql# echo "/usr/sbin/mysqld { }" > /etc/apparmor.d/usr.sbin.mysqld
root@rafael-VirtualBox:/var/lib/mysql# apparmor_parser -v -R /etc/apparmor.d/usr.sbin.mysqld
Removal succeeded for "/usr/sbin/mysqld".
root@rafael-VirtualBox:/var/lib/mysql# systemctl restart mariadb
root@rafael-VirtualBox:/var/lib/mysql# systemctl status mariadb
● mariadb.service - MariaDB 10.3.22 database server
     Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2020-06-04 21:27:03 CDT; 5s ago
       Docs: man:mysqld(8)
             https://mariadb.com/kb/en/library/systemd/
    Process: 78643 ExecStartPre=/usr/bin/install -m 755 -o mysql -g root -d /var/run/mysqld (code=exited, status=0/SUCCESS)
    Process: 78655 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 78657 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_STAR>
    Process: 78745 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
    Process: 78747 ExecStartPost=/etc/mysql/debian-start (code=exited, status=0/SUCCESS)
   Main PID: 78713 (mysqld)
     Status: "Taking your SQL requests now..."
      Tasks: 31 (limit: 4616)
     Memory: 60.2M
     CGroup: /system.slice/mariadb.service
             └─78713 /usr/sbin/mysqld

Jun 04 21:27:03 rafael-VirtualBox mysqld[78713]: 2020-06-04 21:27:03 8 [Warning] Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
Jun 04 21:27:03 rafael-VirtualBox mysqld[78713]: 2020-06-04 21:27:03 9 [Warning] Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78752]: Looking for 'mysql' as: /usr/bin/mysql
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78752]: Looking for 'mysqlcheck' as: /usr/bin/mysqlcheck
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78752]: Version check failed. Got the following error when calling the 'mysql' command line client
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78752]: ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78752]: FATAL ERROR: Upgrade failed
Jun 04 21:27:03 rafael-VirtualBox /etc/mysql/debian-start[78762]: Checking for insecure root accounts.
Jun 04 21:27:03 rafael-VirtualBox mysqld[78713]: 2020-06-04 21:27:03 10 [Warning] Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)
Jun 04 21:27:03 rafael-VirtualBox debian-start[78765]: ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

答案1

好的,我想我已经让它工作了。

按照上述步骤操作后,AppArmor 的错误提供了一组很好的指示命令来安装数据库:

root@rafael-VirtualBox:/opt/stack# mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system


PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h rafael-VirtualBox password 'new-password'

Alternatively you can run:
'/usr/bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'

You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl

现在我可以在 Ubuntu 20.04 上访问 Mariadb

stack@rafael-VirtualBox:/usr$ mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 21
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 

版本:

stack@rafael-VirtualBox:/usr$ mysql --version
mysql  Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

相关内容