数据库版本标准化
1.确认Supported Platforms
https://www.mysql.com/support/
2.确认安装版本
推荐:5.7.22 ,8.0.20以后的双数GA版本
3.获取MySQL软件包
https://downloads.mysql.com/archives/community/
4.MD5验证
安装与部署
1. 部署前准备
1.解压
tar -xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
3. 环境清理
# yum remove -y mariadb-libs
# yum install libaio
4. 创建组
# groupadd mysql
5. 创建用户
# useradd -r -g mysql -s /bin/false mysql
5. 创建目录
# mkdir -p /data/3306/data/
6. 复制以及创建软连接
# cd /usr/local/
# cp /opt/mysql-8.0.24-linux-glibc2.12-x86_64 ./ -rp
# ln -s mysql-8.0.24-linux-glibc2.12-x86_64/ mysql
2.部署
1.在mysql下创建目录
[root@localhost local]# cd mysql
[root@localhost mysql]# mkdir mysql-files
2. 授权
[root@localhost mysql]# chown mysql.mysql mysql-files
[root@localhost mysql]# chmod 750 mysql-files/
3. 初始化安装--默认配置
[root@localhost mysql]# ./bin/mysqld --initialize --user=mysql
2022-05-15T09:16:50.594508Z 0 [System] [MY-013169] [Server] /usr/local/mysql-8.0.24-linux-glibc2.12-x86_64/bin/mysqld (mysqld 8.0.24) initializing of server in progress as process 2637
2022-05-15T09:16:50.602884Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-05-15T09:16:50.995550Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-05-15T09:16:51.624080Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tFsl6zx2Cp<l
##默认密码 tFsl6zx2Cp<l
##[root@localhost mysql]# ./bin/mysqld --initialize-insercute --user=mysql 空密码
4. 创建RSA文件和SSL文件确保加密功能 ##银行可能会有,互联网基本不会设置
[root@localhost mysql]# bin/mysql_ssl_rsa_setup
5. 启动mysql
[root@localhost mysql]# ./bin/mysqld_safe --user mysql &
6. 客户端方式登陆mysql
[root@localhost mysql]# mysql -uroot -p'tFsl6zx2Cp<l' -hlocalhost -P3306
7. 修改密码
mysql> ALTER USER USER() IDENTIFIED BY 'Chiyu45D';
8. 接口方式登陆
[root@localhost mysql]# ./bin/mysql -uroot -pChiyu45D -S /tmp/mysql.sock
9. 创建用户并赋权
mysql> create user yuyang@localhost identified by 'Chiyu45D';
Query OK, 0 rows affected (0.01 sec)
mysql> grant all on *.* to yuyang@localhost with grant option;
Query OK, 0 rows affected (0.00 sec)
10. 将mysql命令加入到系统命令
[root@localhost mysql]# vim /etc/profile
在文档最下方加入如下语句:
export PATH=/usr/local/mysql/bin:$PATH
[root@localhost mysql]# source /etc/profile
注:系统安装一般用于测试环境,生产环境一般会自定义安装
系统安装会有一些缺点,例如
1、sock文件在/tmp目录下
2、日志文件在/var/log目录下
3、配置文件在/etc/my.cnf目录下
文章评论