MySQL5.7二进制安装包
2020-06-06 本文已影响0人
王哈哈就很棒
1.从清华大学开源软件镜像站下载二进制包
wget https://mirrors.tuna.tsinghua.edu.cn/mysql/downloads/MySQL-5.7/mysql-5.7.28-el7-x86_64.tar.gz
2.解压缩&重命名
tar -xvf mysql-5.7.28-el7-x86_64.tar.gz
mv mysql-5.7.28-el7-x86_64 /usr/local/mysql
3.添加mysql
用户&授权文件权限
useradd -s /sbin/nologin -M mysql
chown -R mysql:mysql /usr/local/mysql
4.编辑配置文件
vim /etc/my.cnf
[mysqld]
# GENERAL
datadir=/app/data
socket=/app/data/mysql.sock
user=mysql
default-storage-engine=InnoDB
[mysqld_safe]
log-error=/app/data/mysql-error.log
pid-file=/app/data/mysqld.pid
[client]
socket=/app/data/mysql.sock
5.初始化
cd /usr/local/mysql/bin
mkdir /app
./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/app/data
6.记住临时密码(在最后一行)
2020-06-04T03:05:04.010060Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2020-06-04T03:05:04.417360Z 0 [Warning] InnoDB: New log files created, LSN=45790
2020-06-04T03:05:04.487914Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2020-06-04T03:05:04.549839Z 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: 3022d4be-a610-11ea-a416-000c29151353.
2020-06-04T03:05:04.551718Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2020-06-04T03:05:06.549468Z 0 [Warning] CA certificate ca.pem is self signed.
2020-06-04T03:05:07.057806Z 1 [Note] A temporary password is generated for root@localhost: UCivQQXqa8.j
7.开启ssl
连接
./mysql_ssl_rsa_setup --datadir=/app/data
8.配置服务相关
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql
9.修改mysqld
里的basedir
和datadir
vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/app/data
10.启动
systemctl start mysqld
systemctl daemon-reload
mysql -uroot -p
11.修改密码
alter user 'root'@'localhost' identified by 'Aa.bb9988';