Percona MySQL 5.7 Linux通用二進位制包安裝(CentOS 6.5)
MySQL對libaio庫有依賴關係,如果沒有這個包,資料目錄初始化和接下來的服務啟動會失敗。
yum install libaio
建立軟體安裝目錄
mkdir /mysql_software_57
下載軟體
Percona官網的下載頁面有兩個二進位制Tar包,分別對應不同的發行版本
ssl100 - Debian/Ubuntu
ssl101 - for CentOS 6 and CentOS 7
cd /mysql_software
wget
解壓安裝包
[root@localhost mysql_software_57]# tar xvfz Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# ls
Percona-Server-5.7.17-11-Linux.x86_64.ssl101
Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# rm -rf Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# ls
Percona-Server-5.7.17-11-Linux.x86_64.ssl101
[root@localhost mysql_software_57]# mv Percona-Server-5.7.17-11-Linux.x86_64.ssl101/* .
[root@localhost mysql_software_57]# rmdir Percona-Server-5.7.17-11-Linux.x86_64.ssl101/
建立mysql使用者
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql
建立資料目錄和日誌目錄
[root@localhost mysql_software_57]# mkdir /mysql_data_57
[root@localhost mysql_software_57]# mkdir /mysql_log_57
[root@localhost mysql_software_57]# chown -R mysql.mysql /mysql_log_57/
編輯配置檔案
[root@localhost mysql_software_57]# vim /etc/my.cn
初始化MySQL資料庫的資料檔案路徑,並且建立系統表
5.7.6及以上版本,要使用mysqld來初始化資料庫
[root@localhost mysql_software_57]# bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql
...
2017-04-02T07:54:13.022906Z 0 [Note] Shutting down slave threads
2017-04-02T07:54:13.022915Z 0 [Note] Forcefully disconnecting 0 remaining clients
2017-04-02T07:54:13.068736Z 0 [Note] Binlog end
2017-04-02T07:54:13.072400Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-04-02T07:54:13.072548Z 0 [Note] InnoDB: Starting shutdown...
2017-04-02T07:54:13.173584Z 0 [Note] InnoDB: Dumping buffer pool(s) to /mysql_data_57/ib_buffer_pool
2017-04-02T07:54:13.174062Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170402 0:54:13
2017-04-02T07:54:14.956340Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2017-04-02T07:54:16.679052Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2411492
2017-04-02T07:54:16.679587Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
啟動資料庫
[root@localhost mysql_software_57]# bin/mysqld_safe --defaults-file=/etc/my.cnf &
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17-11-log 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.
yum install libaio
建立軟體安裝目錄
mkdir /mysql_software_57
下載軟體
Percona官網的下載頁面有兩個二進位制Tar包,分別對應不同的發行版本
ssl100 - Debian/Ubuntu
ssl101 - for CentOS 6 and CentOS 7
cd /mysql_software
wget
解壓安裝包
[root@localhost mysql_software_57]# tar xvfz Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# ls
Percona-Server-5.7.17-11-Linux.x86_64.ssl101
Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# rm -rf Percona-Server-5.7.17-11-Linux.x86_64.ssl101.tar.gz
[root@localhost mysql_software_57]# ls
Percona-Server-5.7.17-11-Linux.x86_64.ssl101
[root@localhost mysql_software_57]# mv Percona-Server-5.7.17-11-Linux.x86_64.ssl101/* .
[root@localhost mysql_software_57]# rmdir Percona-Server-5.7.17-11-Linux.x86_64.ssl101/
[root@localhost ~]# groupadd mysql
[root@localhost ~]# useradd -r -g mysql -s /bin/false mysql
建立資料目錄和日誌目錄
[root@localhost mysql_software_57]# mkdir /mysql_data_57
[root@localhost mysql_software_57]# mkdir /mysql_log_57
[root@localhost mysql_software_57]# chmod 750 /mysql_data_57/
[root@localhost mysql_software_57]# chown -R mysql.mysql /mysql_data_57/[root@localhost mysql_software_57]# chown -R mysql.mysql /mysql_log_57/
編輯配置檔案
[root@localhost mysql_software_57]# vim /etc/my.cn
點選(此處)摺疊或開啟
- [client]
- port = 3306
- socket = /mysql_data_57/mysql.sock
- [mysqld]
- #MySQL Server layer basic setting
- server-id = 1
- port = 3306
- socket = /mysql_data_57/mysql.sock
- #MySQL Server layer directory setting
- basedir = /mysql_software_57
- datadir = /mysql_data_57
- tmpdir = /mysql_data_57
- #MySQL Server layer connection setting
- max_connections = 900
- #MySQL Server layer connection setting
- max_connections = 900
- max_connect_errors = 100000
- max_allowed_packet = 16M
- back_log = 50
- #MySQL Server layer binlog setting
- log_bin_trust_function_creators = on
- expire_logs_days = 5
- binlog_cache_size = 1M
- log-bin = /mysql_log_57/mysql-bin
- binlog_format = mixed
- #MySQL Server layer memory management setting
- tmp_table_size = 64M
- max_heap_table_size = 64M
- read_buffer_size = 2M
- read_rnd_buffer_size = 16M
- sort_buffer_size = 8M
- join_buffer_size = 16M
- query_cache_size = 0
- thread_stack = 192K
- query_cache_size = 0
- thread_stack = 192K
- #MySQL Server layer transaction management setting
- transaction_isolation = READ-COMMITTED
- autocommit = OFF
- #MySQL Server layer log related setting
- log_warnings = 2 ##this value have been the default value in MySQL 5.7
- slow_query_log = ON
- long_query_time = 2
- slow_query_log_file = /mysql_log_57/mysql-slow.log
- #log_queries_not_using_indexes = 1
- #MySQL Server layer other behaviour setting
- sql_mode = PIPES_AS_CONCAT,IGNORE_SPACE,STRICT_TRANS_TABLES
- event_scheduler = ON
- lower_case_table_names = 1
- explicit_defaults_for_timestamp = ON
- default-storage-engine = INNODB
- explicit_defaults_for_timestamp = ON
- default-storage-engine = INNODB
- ##ft_min_word_len = 4
- # Statistic
- # userstat = ON
- # thread_statistics = ON
- # End statistics
- # MyISAM Engine related setting
- key_buffer_size = 32M
- bulk_insert_buffer_size = 64M
- myisam_sort_buffer_size = 128M
- myisam_max_sort_file_size = 10G
- myisam_repair_threads = 1
- #myisam_recover
- #InnoDB Engine related setting
- #InnoDB memory management related setting
- innodb_buffer_pool_size = 2G
- innodb_max_dirty_pages_pct = 90
- innodb_sync_array_size = 16
- innodb_max_dirty_pages_pct = 90
- innodb_sync_array_size = 16
- #table open cache related
- table_open_cache = 4096
- table_open_cache_instances = 16
- #innodb_additional_mem_pool_size = 16M ##This variable have been removed MySQL 5.7
- #innodb_numa_interleave = 1 ##Only work with Percona 5.6.27 and later
- ##InnoDB engine I/O related setting
- innodb_write_io_threads = 8
- innodb_read_io_threads = 8
- innodb_flush_method = O_DIRECT
- #InnoDB engine File management related setting
- innodb_data_file_path = ibdata1:12M:autoextend #10M-->12M, 12M is default values, it is meaningless to set it to 10M
- innodb_file_per_table = 1 #this value have been the default value in MySQL 5.7
- innodb_data_file_path = ibdata1:12M:autoextend #10M-->12M, 12M is default values, it is meaningless to set it to 10M
- innodb_file_per_table = 1 #this value have been the default value in MySQL 5.7
- innodb_file_format = Barracuda #this value have been the default value in MySQL 5.7
- #InnoDB engine undo log related setting
- innodb_undo_directory = /mysql_data_57
- innodb_undo_tablespaces = 4
- innodb_purge_batch_size = 5000
- innodb_purge_threads = 8
- #InnoDB engine redo log related setting
- innodb_flush_log_at_trx_commit = 2
- innodb_log_buffer_size = 8M
- innodb_log_file_size = 256M
- innodb_log_files_in_group = 3
- innodb_log_group_home_dir = /mysql_log_57
- #InnoDB engine lock and transaction management setting
- innodb_lock_wait_timeout = 120
- innodb_lock_wait_timeout = 120
- #InnoDB engine other behaviour setting
- innodb_large_prefix = ON ##this value have been the default value in MySQL 5.7
- innodb_strict_mode = ON ##this value have been the default value in MySQL 5.7
- innodb_checksum_algorithm = crc32 ##this value have been the default value in MySQL 5.7
- [mysqldump]
- quick
- max_allowed_packet = 16M
- [mysql]
- no-auto-rehash
- # Only allow UPDATEs and DELETEs that use keys.
- #safe-updates
- [myisamchk]
- key_buffer_size = 512M
- sort_buffer_size = 512M
- key_buffer_size = 512M
- sort_buffer_size = 512M
- read_buffer = 8M
- write_buffer = 8M
- [mysqlhotcopy]
- interactive-timeout
- [mysqld_safe]
- # Increase the amount of open files allowed per process. Warning: Make
- # sure you have set the global system limit high enough! The high value
- # is required for a large number of opened tables
- open-files-limit = 8192
- log-error = /mysql_log_57/mysqld_error.log
初始化MySQL資料庫的資料檔案路徑,並且建立系統表
5.7.6及以上版本,要使用mysqld來初始化資料庫
[root@localhost mysql_software_57]# bin/mysqld --defaults-file=/etc/my.cnf --initialize-insecure --user=mysql
...
2017-04-02T07:54:13.022906Z 0 [Note] Shutting down slave threads
2017-04-02T07:54:13.022915Z 0 [Note] Forcefully disconnecting 0 remaining clients
2017-04-02T07:54:13.068736Z 0 [Note] Binlog end
2017-04-02T07:54:13.072400Z 0 [Note] InnoDB: FTS optimize thread exiting.
2017-04-02T07:54:13.072548Z 0 [Note] InnoDB: Starting shutdown...
2017-04-02T07:54:13.173584Z 0 [Note] InnoDB: Dumping buffer pool(s) to /mysql_data_57/ib_buffer_pool
2017-04-02T07:54:13.174062Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 170402 0:54:13
2017-04-02T07:54:14.956340Z 0 [Note] InnoDB: Waiting for page_cleaner to finish flushing of buffer pool
2017-04-02T07:54:16.679052Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2411492
2017-04-02T07:54:16.679587Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1"
啟動資料庫
[root@localhost mysql_software_57]# bin/mysqld_safe --defaults-file=/etc/my.cnf &
[root@localhost mysql_software_57]# 2017-04-02T08:02:36.065640Z mysqld_safe Logging to '/mysql_log_57/mysqld_error.log'.
2017-04-02T08:02:36.068876Z mysqld_safe error: log-error set to '/mysql_log_57/mysqld_error.log', however file don't exists. Create writable for user 'mysql'.
[1]+ Exit 1 bin/mysqld_safe --defaults-file=/etc/my.cnf
日誌檔案不存在報錯,手動建立日誌檔案
[root@localhost mysql_log_57]# su - mysql
[mysql@localhost ~]$ cd /mysql_log_57/
[mysql@localhost mysql_log_57]$ touch mysqld_error.log
再次啟動資料庫
[root@localhost mysql_software_57]# bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 37100
[root@localhost mysql_software_57]# 2017-04-02T08:03:44.853263Z mysqld_safe Logging to '/mysql_log_57/mysqld_error.log'.
2017-04-02T08:03:44.857901Z mysqld_safe Logging to '/mysql_log_57/mysqld_error.log'.
2017-04-02T08:03:44.922034Z mysqld_safe Starting mysqld daemon with databases from /mysql_data_57
更改root密碼
[root@localhost mysql_software_57]# bin/mysql -uroot -p2017-04-02T08:02:36.068876Z mysqld_safe error: log-error set to '/mysql_log_57/mysqld_error.log', however file don't exists. Create writable for user 'mysql'.
[1]+ Exit 1 bin/mysqld_safe --defaults-file=/etc/my.cnf
日誌檔案不存在報錯,手動建立日誌檔案
[root@localhost mysql_log_57]# su - mysql
[mysql@localhost ~]$ cd /mysql_log_57/
[mysql@localhost mysql_log_57]$ touch mysqld_error.log
[root@localhost mysql_software_57]# bin/mysqld_safe --defaults-file=/etc/my.cnf &
[1] 37100
[root@localhost mysql_software_57]# 2017-04-02T08:03:44.853263Z mysqld_safe Logging to '/mysql_log_57/mysqld_error.log'.
2017-04-02T08:03:44.857901Z mysqld_safe Logging to '/mysql_log_57/mysqld_error.log'.
2017-04-02T08:03:44.922034Z mysqld_safe Starting mysqld daemon with databases from /mysql_data_57
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.17-11-log 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> set password = password('root');
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.01 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26506993/viewspace-2136501/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Percona MySQL 5.5 Linux通用二進位制包安裝(CentOS 6.9)MySqlLinuxCentOS
- MySQL5.7 linux二進位制安裝MySqlLinux
- Ubuntu24 二進位制包安裝mysql5.7UbuntuMySql
- CentOS6.5二進位制檔案安裝MySQL5.6.39CentOSMySql
- Mysql二進位制包安裝MySql
- MySQL5.7 windows二進位制安裝MySqlWindows
- (OEL 6.3) Mysql6.5二進位制安裝MySql
- Linux平臺(CentOS 6.5) RPM包方式安裝 Mysql 5.7LinuxCentOSMySql
- CentOS 6.5/6.6 安裝mysql 5.7CentOSMySql
- 基於centos7的MySQL5.7二進位制安裝包的本地升級CentOSMySql
- centos 7 二進位制安裝mysql 5.7.25CentOSMySql
- 基於Linux的MySQL5.7的二進位制安裝LinuxMySql
- 使用二進位制包來安裝MySQLMySql
- mysql5.7 for windows二進位制安裝及配置MySqlWindows
- 基於centos7的MySQL5.7二進位制安裝包的邏輯升級CentOSMySql
- MySQL linux二進位制安裝MySqlLinux
- CentOS6.6安裝二進位制壓縮包mysql5.6CentOSMySql
- mysql安裝-----二進位制包安裝及解除安裝MySql
- 【Linux合集】二進位制安裝mysqlLinuxMySql
- CentOS8.1操作系下使用通用二進位制包安裝MySQL8.0(實踐整理自MySQL官方)CentOSMySql
- CentOS7 安裝 MySQL8.0(二進位制)CentOSMySql
- Linux下解除安裝MySQL二進位制包(tar.gz)LinuxMySql
- Mysql for Linux安裝配置之——二進位制安裝MySqlLinux
- MySQL 安裝指南 二進位制安裝MySql
- centos7搭建lnmp安裝二進位制mysql【三】CentOSLNMPMySql
- MySQL 5.7 原始碼安裝、Yum倉庫安裝、RPM安裝、二進位制安裝MySql原始碼
- 【MySQL】Linux下MySQL 5.5、5.6和5.7的RPM、二進位制和原始碼安裝MySqlLinux原始碼
- CentOS安裝使用二進位制方式mysql5.6筆記CentOSMySql筆記
- CentOS7 64位安裝mysql5.7(linux)CentOSMySqlLinux
- mysql二進位制包安裝與配置實戰記錄MySql
- centos7二進位制方式安裝rabbitmqCentOSMQ
- 基於centos7的MySQL8.0二進位制安裝包的本地升級CentOSMySql
- 03二進位制包安裝與介紹
- ubuntu mysql5.6二進位制安裝UbuntuMySql
- 二進位制方式安裝mysql 5.6.15MySql
- 基於centos7的MySQL8.0二進位制安裝包的邏輯升級CentOSMySql
- RHEL 7.2 安裝二進位制MySQL 5.7.18MySql
- yum安裝nginx-php-mysql二進位制NginxPHPMySql