删除MariaDB并安装Mysql
这是在Ubuntu 22.04上验证的方法。
这是使用MySQL而不是MariaDB的方法。
MariaDB 的状态
版本
MariaDB [city]> select version();
+----------------------------------+
| version() |
+----------------------------------+
| 10.6.12-MariaDB-0ubuntu0.22.04.1 |
+----------------------------------+
1 row in set (0.000 sec)
SQL模式
MariaDB [city]> select @@sql_mode;
+-------------------------------------------------------------------------------------------+
| @@sql_mode |
+-------------------------------------------------------------------------------------------+
| STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+-------------------------------------------------------------------------------------------+
1 row in set (0.000 sec)
停止 MariaDB
sudo systemctl stop mariadb
删除MariaDB
sudo apt purge mariadb-server
sudo apt purge mariadb-client
sudo apt purge mariadb-common
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
MySQL的安装
sudo apt install mysql-server mysql-client mysql-common
启动 Mysql
sudo systemctl start mysql
确认MySQL正在运行中
sudo systemctl status mysql
访问 MySQL 数据库
$ sudo mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 70
Server version: 8.0.34 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> select version();
+-----------+
| version() |
+-----------+
| 8.0.34 |
+-----------+
1 row in set (0.01 sec)
mysql>
确认 sql_mode
mysql> select @@sql_mode;
+-----------------------------------------------------------------------------------------------------------------------+
| @@sql_mode |
+-----------------------------------------------------------------------------------------------------------------------+
| ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION |
+-----------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)
mysql>