执行 apt-get install mysql-server出现以下错误
Reading package lists... Done
Building dependency tree
Reading state information... Done
Package mysql-server is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, oris only available from another source
E: Package 'mysql-server' has no installation candidate
下载MySQL apt存储库
https://dev.mysql.com/downloads/repo/apt/
- 选择版本,执行以下命令:
wget https://dev.mysql.com/get/mysql-apt-config_0.8.22-1_all.deb
- 用以下命令安装下载的发布包
dpkg -i mysql-apt-config_0.8.22-1_all.deb
注:dpkg用于安装、删除和检查.deb软件包。该-i标志表示我们想从指定的文件安装
在安装过程中会弹出一个配置框,可选择MySQL版本,默认安装最新版本,配置完选择OK按回车
- 到此完成apt存储库的数据添加,刷新apt
- apt update
注:若想更新apt存储库中mysql的配置,可执行以下指令
sudo dpkg-reconfigure mysql-apt-config
更新后执行 apt-get update 刷新缓存包
安装 MySQL
apt-get install mysql-server mysql-client libmysqlclient-dev
这次就不报错了
安装过程中系统会要求提供root用户的密码,此处密码尽量不要设置成root或123456
后续任务操作这里不在描述:
- 配置文件初始化
- 账号密码初始化
- 账号授权隔离
- 远程访问配置
- 字符集设置,推荐(utf8mb4)
- 等
本文参考 :https://blog.csdn.net/m0_47031476/article/details/125356603