linux中安装docker 安装mysql5.7
时间: 2024-09-10 16:23:13 浏览: 110
在Linux中安装Docker和MySQL 5.7的步骤如下:
首先,安装Docker:
1. 更新软件包索引:
```bash
sudo apt-get update
```
2. 安装一些必要的系统工具:
```bash
sudo apt-get install apt-transport-https ca-certificates curl software-properties-common
```
3. 添加Docker官方的GPG密钥:
```bash
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
```
4. 添加Docker的APT仓库到你的系统:
```bash
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
```
5. 再次更新软件包索引:
```bash
sudo apt-get update
```
6. 安装Docker CE(社区版):
```bash
sudo apt-get install docker-ce
```
7. 验证Docker是否安装成功,并运行:
```bash
sudo systemctl status docker
sudo docker run hello-world
```
接下来,安装MySQL 5.7:
1. 导入MySQL官方的GPG密钥:
```bash
sudo apt-get install dirmngr
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys A4A9406876FCBD3C456770C88C718D3B5072E1F5
```
2. 添加MySQL的APT仓库:
```bash
echo "deb http://repo.mysql.com/apt/ubuntu/ $(lsb_release -cs) mysql-5.7" | sudo tee -a /etc/apt/sources.list.d/mysql-5.7.list
```
3. 再次更新软件包索引:
```bash
sudo apt-get update
```
4. 安装MySQL服务器:
```bash
sudo apt-get install mysql-server-5.7
```
5. 启动MySQL服务,并设置开机自启:
```bash
sudo systemctl start mysql
sudo systemctl enable mysql
```
6. 运行安全安装脚本,设置root密码,移除匿名用户,禁止root远程登录等:
```bash
sudo mysql_secure_installation
```
7. 登录MySQL:
```bash
mysql -u root -p
```
请根据你的Linux发行版和版本选择相应的安装命令。上述步骤适用于基于Debian的系统,如Ubuntu。
阅读全文