0
点赞
收藏
分享

微信扫一扫

rhel 7.3安装mysql 5.7.21——二进制包Percona-Server-5.7.21-20

开源分享 2023-07-25 阅读 12

文档课题:rhel 7.3安装mysql 5.7.21——二进制包Percona-Server-5.7.21-20.
系统:rhel 7.3 64位
数据库:mysql 5.7.21
安装包:Percona-Server-5.7.21-20-Linux.x86_64.ssl101.tar.gz
1、安装包处理
--上传安装包
sftp> lcd F:\installmedium\mysql
sftp> cd /usr/local
sftp> put Percona-Server-5.7.21-20-Linux.x86_64.ssl101.tar.gz

--解压安装包
[root@mysql-leo-percona local]# tar -zxf Percona-Server-5.7.21-20-Linux.x86_64.ssl101.tar.gz

2、创建用户与组
[root@mysql-leo-percona local]# groupadd mysql
[root@mysql-leo-percona local]# useradd -g mysql mysql
[root@mysql-leo-percona local]# chown -R mysql:mysql Percona-Server-5.7.21-20-Linux.x86_64.ssl101
[root@mysql-leo-percona local]# ln -s Percona-Server-5.7.21-20-Linux.x86_64.ssl101 mysql
[root@mysql-leo-percona local]# chown -R mysql:mysql mysql

3、创建目录
[root@mysql-leo-percona ~]# mkdir -p /mysql/data
[root@mysql-leo-percona ~]# mkdir -p /mysql/binlog
[root@mysql-leo-percona ~]# mkdir -p /mysql/bak/file
[root@mysql-leo-percona ~]# chown -R mysql:mysql /mysql

4、创建my.cnf文件
[mysql@mysql-leo-percona ~]$ mkdir etc
[mysql@mysql-leo-percona ~]$ cd etc
[mysql@mysql-leo-percona etc]$ vi my.cnf
添加如下:
[mysql]

#CLIENT#
port                                      = 3306
socket                                    = /mysql/data/mysql.sock

[mysqld]
basedir                                   = /usr/local/mysql
datadir                                   = /mysql/data/
server_id                                 = 1
port                                      = 3306
sql_mode                                  = ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
character_set_server                      = utf8mb4
socket                                    = /mysql/data/mysql.sock
secure-file-priv                          = /mysql/bak/file
log-bin                                   = /mysql/binlog/mysql-bin
log-bin-index                             = /mysql/data/mysql-bin.index
relay-log                                 = /mysql/data/relay-bin
relay-log-index                           = /mysql/data/relay-bin.index

[mysqld_safe]
pid_file                                  = /mysql/data/mysql.pid
log_error                                 = /mysql/data/mysql_error.log

注意:生产环境中参数设置需根据实际情况配置.

5、数据库初始化
$ /usr/local/mysql/bin/mysqld --defaults-file=/home/mysql/etc/my.cnf --initialize --basedir=/usr/local/mysql --datadir=/mysql/data/ --user=mysql
2023-07-25T06:29:18.761538Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2023-07-25T06:29:18.761682Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2023-07-25T06:29:18.761935Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2023-07-25T06:29:18.761944Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.
2023-07-25T06:29:19.436086Z 0 [Warning] InnoDB: New log files created, LSN=45790
2023-07-25T06:29:19.546743Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2023-07-25T06:29:19.634843Z 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: 9621e6df-2ab4-11ee-8438-0050563d0a8c.
2023-07-25T06:29:19.636063Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2023-07-25T06:29:20.159689Z 0 [Warning] CA certificate ca.pem is self signed.
2023-07-25T06:29:20.191648Z 1 [Note] A temporary password is generated for root@localhost: qseWGL7O:wuB

注意:指定配置文件时-defaults-file参数需放第一位,否则初始化可能会出现错误.

6、修改path
[mysql@mysql-leo-percona ~]$ vi .bash_profile
添加如下:
export PATH=$PATH:/usr/local/mysql/bin

7、创建mysql.sock软连接
[mysql@mysql-leo-percona ~]$ ln -s /mysql/data/mysql.sock /tmp/mysql.sock

8、启动mysqld进程
[mysql@mysql-leo-percona ~]$ /usr/local/mysql/bin/mysqld_safe --defaults-file=/home/mysql/etc/my.cnf &
[1] 4180
[mysql@mysql-leo-percona ~]$  mysqld_safe Adding '/usr/local/Percona-Server-5.7.21-20-Linux.x86_64.ssl101/lib/mysql/libjemalloc.so.1' to LD_PRELOAD for mysqld
2023-07-25T06:31:40.958553Z mysqld_safe Logging to '/mysql/data/mysql_error.log'.
2023-07-25T06:31:40.990636Z mysqld_safe Starting mysqld daemon with databases from /mysql/data

9、修改密码
[mysql@mysql-leo-percona ~]$ mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.21-20-log

Copyright (c) 2009-2018 Percona LLC and/or its affiliates
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> set password=password("mysql_4U");
Query OK, 0 rows affected, 1 warning (0.00 sec)

参考网址:https://blog.csdn.net/weixin_44375561/article/details/107290095

举报

相关推荐

0 条评论