基于Debian 12 操作系统将 HestiaCP 中的 MariaDB 数据库改成 MySQL 数据库

由于在“定制化”安装 HestiaCP 面板时勾选了 MySQL 8 会出现Error: Mysql 8 does not support Bookworm yet for Debian Unable to continue的错误,而不得不先勾选 MariaDB来解决问题先。
因为我怕前期不勾选数据库的话到时候不在 Web 界面上提供数据库相关的管理界面。

一、切换前的数据库信息

mysql -v
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.11.6-MariaDB-0+deb12u1 Debian 12

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

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
mysql -V
mysql  Ver 15.1 Distrib 10.11.6-MariaDB, for debian-linux-gnu (x86_64) using  EditLine wrapper

10.11.6说不上太旧但也不算新。

二、卸载 MariaDB
由于可以说是新的数据库,数据什么的都不需要就不进行备份了。

如果有数据在操作前一定要备份!一定要备份!!一定要备份!!!因为我是连配置文件都给卸载删除的

apt-get remove --purge mariadb-server
apt-get remove --purge mariadb-*

三、安装Mysql Server
1、配置APT源

wget https://repo.mysql.com/mysql-apt-config_0.8.29-1_all.deb
dpkg -i mysql-apt-config_0.8.29-1_all.deb

有一点点可惜的就是在线的 APT 源只有 8.0 的,没有到 8.3 的Mysql。

2、安装

apt update
apt-cache search mysql-community-server

我这次的环境要执行apt --fix-broken install清理后才能进行安装。数据库密码复用回原来的 root 密码,且使用回旧的身份验证插件(Use Legacy Authentication Method (Retain MySQL 5.x Compatibility) )来保证兼容性。

三、替换后的数据库版本信息

mysql -V
mysql  Ver 8.0.36 for Linux on x86_64 (MySQL Community Server - GPL)
mysql -v
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 31
Server version: 8.0.36 MySQL Community Server - GPL

Copyright (c) 2000, 2024, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Reading history-file /root/.mysql_history
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

四、题外话
如果有,我打算使用 Mysql 8.3 的,可惜暂时还没找到方法的说。除非编译安装或者使用离线 deb 包?
到时候再说吧!!!

ChiuYut

2024年04月16日

发布者

ChiuYut

咦?我是谁?这是什么地方? Ya ha!我是ChiuYut!这里是我的小破站!