一、mysql.v5.7.26版本包下载
### --- mysql.v5.7.26版本包下载
### --- mysql.v5.7.26官网地址:
~~~ mysql下载地址:
~~~ https://downloads.mysql.com/archives/community/
### --- mysql配置目录说明
/opt/yanqi/software: // 安装文件下载目录
/usr/local/mysql: // Mysql目录安装位置
/data/mysql: // 数据库保存位置
/data/log/mysql // 日志保存位置
二、mysql.v5.7.26版本包安装
### --- 下载mysql.v5.7.26版本包
~~~ # 下载mysql.v5.7.26版本包
~~~ # 下载mysql版本包
[root@localhost ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[root@localhost ~]# ls /opt/yanqi/software/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
/opt/yanqi/software/mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
~~~ # 解压并修改目录名称
[root@localhost ~]# cd /opt/yanqi/software/
[root@localhost software]# tar -zxvf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz
[root@localhost software]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /usr/local/mysql
### --- 创建用户及修改目录属性
~~~ # 创建用户及修改目录属性
~~~ # 创建数据存储目录
[root@localhost ~]# mkdir -p /data/mysql
~~~ # 创建mysql用户、组及目录:新建mysql用户禁止登录
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -s /sbin/nologin -g mysql mysql \
-d /usr/local/mysql
~~~ # 改变目录属有着
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# chown -R mysql .
[root@localhost mysql]# chgrp -R mysql .
[root@localhost mysql]# chown -R mysql /data/mysql
### --- 配置参数
~~~ # 初始化数据库
[root@localhost ~]# cd /usr/local/mysql/
[root@localhost mysql]# bin/mysqld --initialize --user=mysql \
--basedir=/usr/local/mysql --datadir=/data/mysql
~~~输出参数
[Note] A temporary password is generated for root@localhost: U9,<9)0o-FiN
~~~生成临时密码:YFe5.36Ae1?J
~~~ # 定义mysql数据目录
[root@localhost mysql]# bin/mysql_ssl_rsa_setup --datadir=/data/mysql
### --- 修改系统配置文件
~~~ # 修改my.cnf配置文件
[root@localhost ~]# cd /usr/local/mysql/support-files
[root@localhost support-files]# cp my-default.cnf /etc/my.cnf
[root@localhost support-files]# cp mysql.server /etc/init.d/mysql
~~~ # 修改配置参数
[root@localhost ~]# vim /etc/init.d/mysql
~~~修改如下配置参数
basedir=/usr/local/mysql
datadir=/data/mysql
~~~ # 软连接启动文件
[root@localhost ~]# ln -s /usr/local/mysql/bin/mysql /usr/bin
### --- 配置环境变量
~~~ # 配置mysql环境变量
[root@localhost ~]# vim /etc/profile
##MYSQL_HOME
export MYSQL_HOME=/usr/local/mysql
export PATH=$PATH:$MYSQL_HOME/bin
export PATH=$PATH:$MYSQL_HOME/sbin
[root@localhost ~]# source /etc/profile
### --- 启动mysql服务
~~~ # 启动mysql服务
[root@localhost ~]# /etc/init.d/mysql start
### --- 初始化数据库
~~~ # 初始化数据库
[root@localhost ~]# mysql_secure_installation
~~~ 输出参数
Enter password for user root: // 键入root密码
Press y|Y for Yes, any other key for No: n // 确认root密码
Change the password for root ?: y // 修改root密码
New password: // 新密码
Re-enter new password: // 确认新密码
Remove anonymous users? : n // 是否删除匿名用户
Disallow root login remotely? : n // 是否禁用root远程登录权限
Remove test database and access to it? : n // 是否删除测试数据库
Reload privilege tables now? : y // 加载特权表
Success.
### --- 进入数据库初始配置
~~~ # 进入数据库初始配置
[root@localhost ~]# mysql -uroot -p123456
mysql> use mysql;
mysql> set password=password('123456');
mysql> grant all privileges on *.* to 'root'@'%' identified by '123456';
mysql> flush privileges;
mysql> select host,user from user;
附录一:my.cnf配置文件
### --- my.cnf配置文件
[root@localhost ~]# cat my.cnf
[mysqld]
port = 3306
server_id = 22206
basedir = /usr/local/mysql
datadir = /data/mysql
socket = /tmp/mysql.sock
innodb_buffer_pool_size = 10G
character-set-server=utf8
collation-server=utf8_bin
init-connect='SET NAMES utf8'
binlog_format = statement
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
log_bin_trust_function_creators = on sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
lower_case_table_names=1
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor