MySQL binary installation

Source: Internet
Author: User

Installation Environment Preparation:

System version:
[Email protected] ~]# cat/etc/redhat-release
CentOS Linux release 7.4.1708 (Core)
SELinux off:
[Email protected] ~]# Getenforce
Disabled
Firewall shutdown:
[Email protected] ~]# systemctl status Firewalld.service
firewalld.service-firewalld-dynamic Firewall daemon
loaded:loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset:enabled)
Active:inactive (Dead)
DOCS:MAN:FIREWALLD (1)

1. Install dependent packages
Yum Install Libaio-y

2. Download MySQL binary installation package

Https://dev.mysql.com (community site)
https://dev.mysql.com/downloads/file/?id=474755 (Download page)


Wget-p/opt/https://cdn.mysql.com//downloads/mysql-5.7/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz

Parameter description:-P Download all files for the HTML page to display as normal.
-P. /local Save all files and directories to a locally specified directory.

3. Create user

Useradd-s/sbin/nologin-m MySQL

4. Unzip, create a directory, and create a soft connection

mkdir/opt/mysql/
Tar zxf/opt/mysql-5.7.21-linux-glibc2.12-x86_64.tar.gz-c/opt/mysql/
cd/usr/local/
Ln-s/opt/mysql/mysql-5.7.21-linux-glibc2.12-x86_64

5. Create database related directory (for backup)

MKDIR-PV/DATA/MYSQL/MYSQL3306/{DATA,LOGS,TMP}

6. Change the properties of the relevant directory

Chown-r Mysql.mysql/usr/local/mysql
Chown-r Mysql.mysql/data

7. Create configuration-related files

The configuration file is:/etc/my.cnf

Cat >/etc/my.cnf << EOF

Base

#my. cnf
[Client]
Port = 3306
Socket =/tmp/mysql3306.sock

[MySQL]
prompt= "\[email protected]\h [\d]>"
No-auto-rehash

[Mysqld]
#misc
user = MySQL
Basedir =/usr/local/mysql
DataDir =/data/mysql/mysql3306/data
Tmpdir =/data/mysql/mysql3306/tmp
Port = 3306
Socket =/tmp/mysql3306.sock
Event_scheduler = 0

#timeout
Interactive_timeout = 300
Wait_timeout = 300

#character Set
Character-set-server = UTF8

Open_files_limit = 65535
max_connections = 100
Max_connect_errors = 100000
Lower_case_table_names =1

GTID

Gtid-mode = On
Enforce-gtid-consistency=1

Symi Replication

#rpl_semi_sync_master_enabled =1
#rpl_semi_sync_master_timeout =1000 # 1 Second
#rpl_semi_sync_slave_enabled =1

####### Slow Log ######
Log-output=file
Slow_query_log = 1
Slow_query_log_file = Slow.log
Log-error = Error.log
Log_warnings = 2
Pid-file = Mysql.pid
Long_query_time = 1
#log-slow-admin-statements = 1
#log-queries-not-using-indexes = 1
Log-slow-slave-statements = 1

####### Binlog ######
Binlog_format = row
Server-id = 1003306
Log-bin =/data/mysql/mysql3306/logs/mysql-bin
Max_binlog_size = 256M
Sync_binlog = 0
Expire_logs_days = 10
#procedure
Log_bin_trust_function_creators=1

####### Relay Log ######
Skip_slave_start = 1
Max_relay_log_size = 128M
Relay_log_purge = 1
Relay_log_recovery = 1
Relay-log=relay-bin
Relay-log-index = Relay-bin.index
Log_slave_updates = On
#slave-skip-errors=1032,1053,1062
#skip-grant-tables

####### Buffers & Cache ######
Table_open_cache = 2048
Table_definition_cache = 2048
Table_open_cache = 2048
Max_heap_table_size = 96M
Sort_buffer_size = 128K
Join_buffer_size = 128K
Thread_cache_size = 200
Query_cache_size = 0
Query_cache_type = 0
Query_cache_limit = 256K
Query_cache_min_res_unit = 512
Thread_stack = 192K
Tmp_table_size = 96M
Key_buffer_size = 8M
Read_buffer_size = 2M
Read_rnd_buffer_size = 16M
Bulk_insert_buffer_size = 32M

#myisam
Myisam_sort_buffer_size = 128M
Myisam_max_sort_file_size = 10G
Myisam_repair_threads = 1

#innodb
Innodb_buffer_pool_size = 100M
Innodb_buffer_pool_instances = 1
Innodb_data_file_path = Ibdata1:100m:autoextend
Innodb_flush_log_at_trx_commit = 2
Innodb_log_buffer_size = 8M
Innodb_log_file_size = 100M
Innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 50
innodb_file_per_table = 1
Innodb_rollback_on_timeout
innodb_io_capacity = 2000
Transaction_isolation = read-committed
Innodb_flush_method = O_direct
Eof

8. Initialize the database

cd/usr/local/mysql/
./bin/mysqld--defaults-file=/etc/my.cnf--initialize

9. Create a startup script

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

/etc/init.d/mysqld start

Starting MySQL ....... success! (Start successfully)

10. Create a fast-start environment variable

echo "Export path= $PATH:/usr/local/mysql/bin" >>/etc/profile
Source/etc/profile

11. Check MySQL initial password

grep "Password"/data/mysql/mysql3306/data/error.log
2018-02-01t05:44:04.334666z 1 [Note] A temporary password is generated for [email protected]: USXXW5X.ZZFW (default login password)

12. Modify the initial password

The initial password is: Q=USXXW5X.ZZFW each initialization password will not be the same;
Login database Change Password is: 123456

Mysql-uroot-p Initial Password
mysql> alter User User () identified by ' 123456 ';
Or:
mysql> SET Password=password (' 123456 ');
mysql> flush Privileges;

Description: The password changed here is 123456 and the recommended password is complicated.

or use the following command:
passwd=$ (grep ' password is '/data/mysql/mysql3306/data/error.log | awk ' {print $NF} ')

Mysql-uroot-p "$PASSWD"--CONNECT-EXPIRED-PASSWORD-E "alter user user () identified by ' 123456 ';"

Now that the binary installation of the MySQL database is complete, you will enter a new world of data.

MySQL binary installation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.