Debian11上安装MySQL
Xplorist Lv6

Debian11上安装MySQL

reference-site-list

steps

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
cd /data

# 从 http://repo.mysql.com/ 网址中去寻找最新的.deb包
wget http://repo.mysql.com/mysql-apt-config_0.8.17-1_all.deb

apt-get install ./mysql-apt-config_0.8.17-1_all.deb

# 按Tab选择OK,然后按Enter

apt-get update

apt-get install mysql-server

# 输入root账号密码
# 选择兼容MySQL 5的密码验证方式

# 查看状态
systemctl status mysql

# 设置开机自启动
systemctl enable mysql

# 进入mysql修改密码
mysql -u root -p

use mysql;

select user, host from user;

# 添加root账号的本地和远程权限
update user set host = 'localhost' where user ='root';
update user set host = '%' where user ='root';

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
# 如果上面这条报错,是因为已经使用了mysql_native_password的兼容MySQL5的验证方式,去掉即可
ALTER USER 'root'@'%' IDENTIFIED BY 'password';

# 创建数据库
create database wordpress;

 评论