1. 下载软件包

wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz

2. 解压软件包

# 解压
tar xf mysql-5.7.36-linux-glibc2.12-x86_64.tar.gz
# 移动
mv mysql-5.7.36-linux-glibc2.12-x86_64 /usr/local/mysql

3. 编辑配置文件

3.1 配置文件

# vi /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock
symbolic-links=0

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

!includedir /etc/my.cnf.d

如果没有这个目录手动建立下

mkdir /etc/my.cnf.d

3.2 创建数据目录

mkdir /usr/local/mysql/data

3.3 创建pid文件存放目录

mkdir /var/run/mysqld

3.4 创建启动用户mysql

useradd mysql -s /sbin/nologin

3.5 将上面创建的数据目录及pid文件存放目录权限都改为mysql

chown mysql.mysql /var/run/mysqld/ /usr/local/mysql/  -R

4. 初始化数据库仓库

/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data

4.1 注意

这里如果执行上面命令报如下的错误

2021-12-29 09:33:06 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2021-12-29 09:33:06 [ERROR]   Child process: /usr/local/mysql/bin/mysqldterminated prematurely with errno= 32
2021-12-29 09:33:06 [ERROR]   Failed to execute /usr/local/mysql/bin/mysqld --bootstrap --datadir=/usr/local/mysql/data --lc-messages-dir=/usr/local/mysql/share --lc-messages=en_US --basedir=/usr/local/mysql
-- server log begin --

解决办法:

yum install libaio numactl -y

5. 添加MySQL全局环境变量

echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
source /etc/profile

6. 启动MySQL,并设为开机启动

# 复制启动文件
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

# 启动mysql
service mysqld start

7. 更改密码

7.1 查看初始密码

# cat /root/.mysql_secret 
# Password set for user 'root@localhost' at 2021-12-29 10:15:21 
'''显示你的密码'''

7.2 修改密码

mysqladmin -u root password "123456" -p
Enter password: #这里输入上面查看到的密码

7.3 验证密码是否修改成功

mysql -p123456 -e "show databases;"
mysql: [Warning] Using a password on the command line interface can be insecure.
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+

8. 设置远程登录

mysql> grant all on *.* to 'root'@'%' identified by '123456';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql> \q
Bye

9. 设置防火墙通过

firewall-cmd --permanent --add-port=3306/tcp --zone=public
firewall-cmd --reload

docker-compose-amd64.yml

version: '3'

services: 
    caddy: 
        image: nginx:alpine
        ports: 
            - 80:80
            - 443:443
        volumes: 
            - /dockercnf/nginx/conf.d:/etc/nginx/conf.d
            - /dockercnf/nginx/ssl:/etc/nginx/ssl
        networks: 
            - cloudreve-network
        restart: unless-stopped

    aria2: 
        image: p3terx/aria2-pro
        logging: 
            options: 
                max-size: 1m
        ports: 
            - 6800:6800
            - 6888:6888
            - 6888:6888/udp
        environment: 
            - PUID=${CLOUDREVE_PUID}
            - PGID=${CLOUDREVE_PGID}
            - RPC_SECRET=${ARIA2_RPC_SECRET}
        volumes: 
            - ${ARIA2_CONFIG_PATH}:/config
            - ${TEMP_FOLDER_PATH}:/downloads
        networks: 
            - cloudreve-network
        restart: unless-stopped

    cloudreve: 
        image: xavierniu/cloudreve
        environment: 
            - PUID=${CLOUDREVE_PUID}
            - PGID=${CLOUDREVE_PGID}
        volumes: 
            - ${CLOUDREVE_UPLOAD_PATH}:/cloudreve/uploads
            - ${TEMP_FOLDER_PATH}:/downloads
            - ${CLOUDREVE_CONF_PATH}:/cloudreve/config
            - ${CLOUDREVE_DB_PATH}:/cloudreve/db
            - ${CLOUDREVE_AVATAR_PATH}:/cloudreve/avatar
        networks: 
            - cloudreve-network


networks: 
    cloudreve-network:

docker-compose-env-example.env

# Required

# > PUID & PGID
CLOUDREVE_PUID=<PUID>
CLOUDREVE_PGID=<PGID>

# > Aria2
ARIA2_RPC_SECRET=<SECRET>

# Optional
# But I highly recommend you keep items below as default 
# unless you know what you are doing.

# > Temp download folder for Aria2 & Cloudreve
TEMP_FOLDER_PATH=/dockercnf/aria2/temp

# > Aria2
ARIA2_CONFIG_PATH=/dockercnf/aria2/conf

# > Cloudreve
CLOUDREVE_UPLOAD_PATH=/sharedfolders
CLOUDREVE_CONF_PATH=/dockercnf/cloudreve/config
CLOUDREVE_DB_PATH=/dockercnf/cloudreve/db
CLOUDREVE_AVATAR_PATH=/dockercnf/cloudreve/avatar