[root@mysql-1 ~]# rpm -aq | grep mariadb
mariadb-libs-5.5.44-2.el7.centos.x86_64
[root@mysql-1 ~]# yum remove mariadb-libs -y
[root@mysql-1 ~]# useradd mysql -s /sbin/nologin
[root@mysql-1 ~]# id mysql
uid=1000(mysql) gid=1000(mysql) groups=1000(mysql)
[root@mysql-1 ~]# mkdir -p /app/database
[root@mysql-1 ~]# mkdir -p /data/3306
[root@mysql-1 ~]# mkdir -p /binlog/3306
[root@mysql-1 log]# chown mysql.mysql -R /app/database/ /data/3306/ /binlog/3306/
上传MySQL 5.7二进制包到/app/database/
[root@mysql-1 database]# tar xvf mysql-5.7.28-linux-glibc2.12-x86_64.tar.gz
[root@mysql-1 database]# mv mysql-5.7.28-linux-glibc2.12-x86_64/ mysql-5.7.28
[root@mysql-1 ~]# vim /etc/profile
添加如下内容
export PATH=/app/database/mysql-5.7.28/bin:$PATH
生效配置
[root@mysql-1 ~]# source /etc/profile
[root@mysql-1 ~]# mysql -V
mysql Ver 14.14 Distrib 5.7.28, for linux-glibc2.12 (x86_64) using EditLine wrapper
[root@mysql-1 data]# mysqld --initialize-insecure --user=mysql --basedir=/app/database/mysql-5.7.28 --datadir=/data/3306
显示一下内容表示初始化成功
2020-03-31T05:10:13.149093Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-03-31T05:10:13.252907Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-03-31T05:10:13.273152Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-03-31T05:10:13.328798Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: e6ddd3b8-730d-11ea-b7ea-000c2985b0a2.
2020-03-31T05:10:13.329424Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2020-03-31T05:10:13.753966Z 0 [Warning] CA certificate ca.pem is self signed.
2020-03-31T05:10:14.041334Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
初始化方式
mysql --initialize
:初始化完成之后会有一个12位的临时密码,但是必须在使用mysql之前重置这个密码,否则没法使用。密码管理使用严格模式:3种密码复杂度mysql --initialize-insecure
:初始化完成后无密码,可后期随时修改。无密码复杂度要求mysql_install_db
cat > /etc/my.cnf << EOF
[mysqld]
user=mysql
basedir=/app/database/mysql-5.7.28
datadir=/data/3306
server_id=6
port=3306
socket=/tmp/mysql.sock
[mysql]
socket=/tmp/mysql.sock
EOF
[root@mysql-1 support-files]# cd /app/database/mysql-5.7.28/support-files/
# 拷贝MySql启动脚本至系统软件管理目录中
[root@mysql-1 support-files]# cp mysql.server /etc/init.d/mysqld
[root@mysql-1 ~]# service mysqld start/stop/restart
[root@mysql-1 ~]# chkconfig --add mysqld
[root@mysql-1 ~]# systemctl start mysqld
# 设置开机自启
[root@mysql-1 ~]# systemctl enable mysqld
原文:https://www.cnblogs.com/xiasir/p/12963982.html