🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
### 1.**目录定义** 安装包文件下载目录:/home Mysql目录安装位置:/www/server/mysql 数据库保存位置:/www/server/mysql/data 日志保存位置:/www/server/mysql/log ### 2. **下载二进制安装包** ``` [root@local ~]# cd /home [root@local ~]# wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz ``` ### 3. **创建用户组** 创建一个用户组mysql和一个不能执行shell登录的用户mysql ``` [root@local ~]# groupadd mysql [root@local ~]# useradd -r -g mysql -s /bin/false mysql ``` ### 4. **解压安装** ``` [root@local ~]# tar zxvf mysql-5.7.25-linux-glibc2.12-x86_64.tar.gz [root@local ~]# mv mysql-5.7.25-linux-glibc2.12-x86_64 /www/server/mysql [root@local ~]# cd /www/server/mysql [root@local ~]# mkdir data [root@local ~]# mkdir log ``` ### 5. **给相关权限** ``` [root@local ~]# chown -R mysql:mysql /www/server/mysql [root@local ~]# chmod -R 750 /www/server/mysql/data [root@local ~]# chmod -R 750 /www/server/mysql/log ``` ### 6. **配置** ``` [root@local ~]# /www/server/mysql/bin/mysql_install_db --user=mysql --basedir=/www/server/mysql --datadir=/www/server/mysql/data [root@local ~]# bin/mysql_install_db --user=mysql [root@local ~]# bin/mysqld --initialize --user=mysql [root@local ~]# bin/mysql_ssl_rsa_setup [root@local ~]# bin/mysqld_safe --user=mysql & [root@local ~]# cp support-files/my-default.cnf /etc/my.cnf [root@local ~]# cp support-files/mysql.server /etc/init.d/mysql.server ```