您的位置:首页 > 运维架构 > Linux

Percona MySQL 5.7 Linux通用二进制tar包安装(CentOS 6.5)

2017-03-24 11:50 756 查看
MySQL对libaio库有依赖关系,如果没有这个包,数据目录初始化和接下来的服务启动会失败。
yum install libaio

创建软件安装目录
mkdir /mysql_software

下载软件
Percona官网的下载页面有两个二进制Tar包,分别对应不同的发行版本
ssl100 - Debian/Ubuntu
ssl101 - for CentOS 6 and CentOS 7
cd /mysql_software
wget https://www.percona.com/downloads/Percona-Server-5.7/Percona-Server-5.7.17-11/binary/tarball/Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
解压安装包
[root@localhost mysql_software]# tar xvfz Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
建立软链接
[root@localhost mysql_software]# ln -s Percona-Server-5.7.17-11-Linux.x86_64.ssl101 data

创建mysql用户
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql

创建数据目录
[root@localhost ~]# mkdir /mysql_data
[root@localhost ~]# chmod 750 /mysql_data/
[root@localhost ~]# chown -R mysql /mysql_data/
[root@localhost ~]# chgrp -R mysql /mysql_data/
[root@localhost /]# chown -R mysql /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101

[root@localhost /]# chgrp -R mysql /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101

初始化MySQL数据库的数据文件路径,并且创建系统表

[root@localhost ~]# cd /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# bin/mysqld --initialize-insecure --user=mysql --basedir=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101 --datadir=/mysql_data
#./bin/mysqld --defaults-file=/opt/mysql_5.7.17/etc/my.cnf --initialize-insecure --user=mysql(配置文件初始化)

查看日志,若没有配置日志,则会将信息输出到屏幕
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# cat log/mysqld_0.log
2017-02-12T16:11:08.723816Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-02-12T16:11:11.544515Z 0 [Warning] InnoDB: New log files created, LSN=45790
2017-02-12T16:11:12.004732Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2017-02-12T16:11:12.075390Z 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: df2a104a-f13d-11e6-8cdd-000c292a9abe.
2017-02-12T16:11:12.076947Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2017-02-12T16:11:12.446251Z 0 [Warning] CA certificate ca.pem is self signed.
2017-02-12T16:11:12.756727Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# bin/mysql_ssl_rsa_setup

如果配置文件中没有指定数据文件的路径,默认路径是/var/lib/mysql
如果在配置文件/etc/my.cnf中指定了数据文件的路径,则会根据这个路径进行生成
mkdir -p /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log
[root@localhost ~]# cat /etc/my.cnf
[mysqld]
basedir = /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101
datadir=/mysql_data
socket=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysqld_0.log

[mysqld_safe]
pid-file=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysqld.pid

更改软件目录和数据目录权限
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# chown -R root /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101

[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# chown -R mysql /mysql_data/

启动数据库
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# bin/mysql --socket=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysql.sock
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.17-11 Percona Server (GPL), Release 11, Revision f60191c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

mysql> select user, host from mysql.user;
+-----------+-----------+
| user | host |
+-----------+-----------+
| mysql.sys | localhost |
| root | localhost |
+-----------+-----------+
2 rows in set (0.00 sec)
更改root密码
mysql> set password = password('root');
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Level | Code | Message |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Warning | 1287 | 'SET PASSWORD = PASSWORD('')' is deprecated and will be removed in a future release. Please use SET PASSWORD = '' instead |
+---------+------+-------------------------------------------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# bin/mysql -uroot -p --socket=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysql.sock
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.17-11 Percona Server (GPL), Release 11, Revision f60191c

Copyright (c) 2009-2016 Percona LLC and/or its affiliates
Copyright (c) 2000, 2016, 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>

关闭数据库
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# ./bin/mysqladmin -uroot shutdown -p --socket=/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysql.sock
Enter password:
2017-02-12T16:32:21.505954Z mysqld_safe mysqld from pid file /mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysqld.pid ended
[1]+ Done ./bin/mysqld_safe --defaults-file=/etc/my.cnf
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# ps -ef|grep mysql
root 4132 2523 0 08:32 pts/0 00:00:00 grep mysql

[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# ./bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 4134
[root@localhost Percona-Server-5.7.17-11-Linux.x86_64.ssl101]# mysqld_safe Adding '/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/lib/mysql/libjemalloc.so.1' to LD_PRELOAD for mysqld
2017-02-12T16:32:41.691299Z mysqld_safe Logging to '/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysqld_0.log'.
2017-02-12T16:32:41.701689Z mysqld_safe Logging to '/mysql_software/Percona-Server-5.7.17-11-Linux.x86_64.ssl101/log/mysqld_0.log'.
2017-02-12T16:32:41.742249Z mysqld_safe Starting mysqld daemon with databases from /mysql_data
本文出自http://blog.itpub.net/26506993/viewspace-2133434/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息