前言
今天在新装的Debian11上安装MSYQL8,出现了如下错误
看了下是签名错误,下面具体提供下解决版本
安全mysql
vim /etc/apt/sources.list 我使用的阿里源
deb https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye main non-free contrib
deb https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb-src https://mirrors.aliyun.com/debian-security/ bullseye-security main
deb https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-updates main non-free contrib
deb https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
deb-src https://mirrors.aliyun.com/debian/ bullseye-backports main non-free contrib
首先安装DEB Package;这里按照0.8.22-1做演示
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.22-1_all.deb
sudo apt-get update
其中安装mysql的时候需要全部选择 enabled
更新的时候会报错
遇到 W: GPG error: http://repo.mysql.com/apt/debian bullseye InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY B7B3B788A8D3785C 错误时,表示您的系统缺少 MySQL APT 仓库的公钥
解决办法:
首先获取并添加 GPG 公钥:
使用以下命令下载并添加 MySQL 的 GPG 公钥:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys B7B3B788A8D3785C
或者,也可以直接下载并添加
wget https://repo.mysql.com/RPM-GPG-KEY-mysql
sudo apt-key add RPM-GPG-KEY-mysql
更新 APT 软件包列表:
添加密钥后,运行以下命令更新软件包列表:
sudo apt-get update
安装 MySQL:
然后可以尝试安装 MySQL:
sudo apt-get install mysql-server
可以看到可以正常更新和安装
最后设置下对外访问
mysql -uroot -p
use mysql
select host,user from user;
可以看到是localhost
修改为全局
update user set host = '%' where user = 'root';
select host,user from user;
修改成功:
刷新退出
FLUSH PRIVILEGES;
exit
修改端口号
vi /etc/mysql/mysql.conf.d/mysqld.cnf
在末行添加 port = 9285
然后重启服务
service mysql restart
查看
mysql -u root -p
show global variables like 'port';
修改成功