数据库版本标准化
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.解压
tar -xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
- 环境清理
yum remove -y mariadb-libs
yum install libaio
- 创建组
groupadd mysql
- 创建用户
useradd -r -g mysql -s /bin/false mysql
- 创建目录
mkdir -p /data/3306/data/
- 复制以及创建软连接
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
- 授权
[root@localhost mysql]# chown mysql.mysql mysql-files
[root@localhost mysql]# chmod 750 mysql-files/
- 初始化安装–默认配置
[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
默认密码 tFsl6zx2Cp
[root@localhost mysql]# ./bin/mysqld –initialize-insercute –user=mysql 空密码
- 创建RSA文件和SSL文件确保加密功能 ##银行可能会有,互联网基本不会设置
[root@localhost mysql]# bin/mysql_ssl_rsa_setup
- 启动mysql
[root@localhost mysql]# ./bin/mysqld_safe –user mysql &
- 客户端方式登陆mysql
[root@localhost mysql]# mysql -uroot -p’tFsl6zx2Cp
- 修改密码
mysql> ALTER USER USER() IDENTIFIED BY ‘Chiyu45D’;
- 接口方式登陆
[root@localhost mysql]# ./bin/mysql -uroot -pChiyu45D -S /tmp/mysql.sock
- 创建用户并赋权
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)
- 将mysql命令加入到系统命令
[root@localhost mysql]# vim /etc/profile
在文件底部添加以下声明:
[En]
Add the following statement at the bottom of the document:
export PATH=/usr/local/mysql/bin:$PATH
[root@localhost mysql]# source /etc/profile
注:系统安装一般在测试环境中使用,生产环境一般会定制安装。
[En]
Note: the system installation is generally used in the test environment, and the production environment will generally customize the installation.
系统安装有一些缺点,例如
[En]
There are some disadvantages in system installation, such as
1、sock文件在/tmp目录下
2、日志文件在/var/log目录下
3、配置文件在/etc/my.cnf目录下
Original: https://www.cnblogs.com/Songhn9/p/16273957.html
Author: 她脚踝银铃响了
Title: MySQL系统安装与部署
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/505379/
转载文章受原作者版权保护。转载请注明原作者出处!