1.添加 MySQL APT 仓库
$ sudo apt update
$ wget https://repo.mysql.com//mysql-apt-config_0.8.29-1_all.deb
$ sudo dpkg -i mysql-apt-config_0.8.29-1_all.deb
2.安装 MySQL 8.0
$ sudo apt update
$ sudo apt install mysql-server
如报key错误 ...the public key is not available: NO_PUBKEY B7B3B788A8D3785C
$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
3.检查版本
$ apt policy mysql-server
mysql-server:
Installed: 8.0.37-1debian12
Candidate: 8.0.37-1debian12
Version table:
*** 8.0.37-1debian12 500
500 http://repo.mysql.com/apt/debian bookworm/mysql-8.0 amd64 Packages
100 /var/lib/dpkg/status
查看 MySQL 服务状态
$ systemctl status mysql
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; preset: enabled)
Active: active (running) since Sun 2024-06-02 19:45:52 CST; 4min 28s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
...
root账号登录验证
$ mysql -u root -p
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.37 |
+-----------+