Debian 10 安装MySQL 8.0

添加MySQL软件存储库MySQL APT

1
2
~# wget https://dev.mysql.com/get/mysql-apt-config\_0.8.13-1\_all.deb
~# dpkg -i mysql-apt-config\_0.8.13-1\_all.deb //在软件包安装过程中,将提示您配置MySQL APT存储库,以选择MySQL服务器的版本以及要安装的其他组件。保留默认选项以安装最新版本。完成后,点击Enter或转到OK并点击Enter。
1
2
~# apt update
~# apt install mysql-server

在安装过程中,将要求您为MySQL设置数据库根用户密码,建议输入安全且强度高的密码,输入两遍后确认。

了解MySQL使用的基于SHA256的密码方法的新身份验证系统,然后单击“确定”。

设置MySQL密码验证

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
~# systemctl status mysql //查看MySQL运行状态
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: active (running) since Thu 2020-12-08 12:56:12 UTC; 3s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 2673 ExecStartPre=/usr/share/mysql-8.0/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 2709 (mysqld)
Status: "Server is operational"
Tasks: 39 (limit: 4915)
Memory: 378.4M
CGroup: /system.slice/mysql.service
└─2709 /usr/sbin/mysqld

Dec 08 12:56:12 tecmint systemd[1]: Starting MySQL Community Server...
Dec 08 12:56:12 tecmint systemd[1]: Started MySQL Community Server.

常用systemctl命令

1
2
3
4
~# systemctl start mysql //启动
~# systemctl restart mysql //重启
~# systemctl stop mysql //停止
~# systemctl reload mysql //重载

测试访问mysql shell

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
~# mysql -uroot -p //root访问mysql shell
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5268
Server version: 8.0.22 MySQL Community Server - GPL

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.

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

mysql>