阿里云服务器安装mysql5.7
时间: 2023-11-08 17:05:06 浏览: 114
以下是在阿里云服务器上安装MySQL 5.7的步骤:
1. 更新系统并安装必要软件:
```
sudo yum update
sudo yum install wget
sudo yum install openssl openssl-devel
```
2. 下载mysql源码安装包:
```
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
```
3. 解压安装包并移动到/usr/local目录下:
```
tar -xzvf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
sudo mv mysql-5.7.35-linux-glibc2.12-x86_64 /usr/local/mysql
```
4. 创建MySQL用户和用户组,并修改权限:
```
sudo groupadd mysql
sudo useradd -r -g mysql mysql
sudo chown -R mysql:mysql /usr/local/mysql
```
5. 初始化MySQL:
```
cd /usr/local/mysql/bin
sudo ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
```
6. 启动MySQL服务:
```
sudo ./mysqld_safe --user=mysql &
```
7. 修改root账号密码:
```
sudo ./mysql_secure_installation
```
8. 设置MySQL开机自启动:
```
sudo cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql.server
sudo chmod +x /etc/init.d/mysql.server
sudo chkconfig --add mysql.server
sudo chkconfig mysql.server on
```
阅读全文