Installation and deployment MySQL-5.7.13 in CentOS6.7 64-bit environment

Source: Internet
Author: User
Tags localhost mysql

Installation and deployment MySQL-5.7.13 in CentOS6.7 64-bit environment

System Environment:
[Root @ localhost ~] # Cat/etc/RedHat-release
CentOS release 6.7 (Final)
[Root @ localhost tools] # uname-
Linux localhost 2.6.32-573.22.1.el6.x86 _ 64 #1 SMP Wed Mar 23 03:35:39 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
[Root @ localhost tools] #
Software preparation:
[Root @ localhost tools] # pwd
/Opt/tools
[Root @ localhost tools] # ll
Total 674208
-Rw-r -- 1 root 639864682 Jul 22 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
-Rw-r -- 1 root 50516207 May 25 mysql-5.7.13.tar.gz
[Root @ localhost tools] #
Unzip and install:
[Root @ localhosttools] # tar xf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
[Root @ localhost tools] # ll
Total 674212
Drwxr-xr-x 9 7161 wheel 4096 May 25 mysql-5.7.13-linux-glibc2.5-x86_64
-Rw-r -- 1 root 639864682 Jul 22 mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
-Rw-r -- 1 root 50516207 May 25 mysql-5.7.13.tar.gz
[Root @ localhost tools] #
[Root @ localhost tools] # mv mysql-5.7.13-linux-glibc2.5-x86_64/usr/local/mysql
[Root @ localhost tools] #
Initialization (generate the initial password ):
[Root @ localhost mysql] #./bin/mysqld -- initialize -- user = mysql -- basedir =/usr/local/mysql -- datadir =/data/mysql/data
2016-07-22T09: 58: 15.001776Z 0 [Warning] InnoDB: New log files created, LSN = 45790
2016-07-22T09: 58: 15.062066Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-07-22T09: 58: 15.073009Z 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: cebfb8a6-4ff2-11e6-8c8d-005056a01a07.
2016-07-22T09: 58: 15.074370Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql. gtid_executed' cannot be opened.
2016-07-22T09: 58: 15.075736Z 1 [Note] A temporary password is generated for root @ localhost: k_1ljzVh3 <-,
[Root @ localhost mysql] #
PS: New Features of mysql5.7: As shown above, mysql_install_db is no longer recommended. We recommend that you change it to mysqld -- initialize to complete instance initialization.
 
Add MySQL as the System Service:
[Root @ localhost mysql] # cp support-files/mysql. server/etc/init. d/mysqld
[Root @ localhost mysql] # chkconfig mysqld on
[Root @ localhost mysql] # chkconfig -- list | grep mysqld
Mysqld 0: off 1: off 2: on 3: on 4: on 5: on 6: off
[Root @ localhost mysql] # chmod 755/etc/init. d/mysqld
 
MySQL service starts, restarts, and stops
[Root @ localhost mysql] # serivce mysqld start
[Root @ localhost mysql] # serivce mysqld stop
[Root @ localhost mysql] # serivce mysqld restart
[Root @ localhost mysql] #
Set environment variables:
[Root @ localhost mysql] # vim/etc/profile
Export PATH =/usr/local/mysql/bin: $ PATH
[Root @ localhost mysql] #
Check whether MySQL is enabled

[Root @ localhost mysql] # cd/usr/local/mysql
[Root @ localhost mysql] # cd support-files/
[Root @ localhost support-files] #./mysql. server start
Starting MySQL... SUCCESS!
If yes, the following error occurs when starting the service:
#./Support-files/mysql. server start
./Support-files/mysql. server: line 276: cd:/usr/local/mysql: No such file or directory
Starting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)
At this time, we need to modify the basedir and datadir directory paths of the/support-files/mysql. server File to the correct mysql basedir and datadir paths, as shown below:
# Vim support-files/mysql. server
--------------------------
...
Basedir =/usr/local/mysql
Datadir =/data/mysql/data
...
--------------------------
#./Support-files/mysql. server start
Starting MySQL... SUCCESS!
Create a configuration file
Back up my. cnf generated by default
# Mv/etc/my. cnf/etc/my. cnf. bak
[Root @ localhost support-files] # cp my-default.cnf/etc/my. cnf
Initialize the root password of a mysql user
Stop mysql service first
# Service mysqld stop
Go to the mysql installation directory and run:
# Cd/usr/local/mysql
#./Bin/mysqld_safe -- skip-grant-tables -- skip-networking &
[1] 6225
[Root @ localhost mysql] #151110 02:46:08 mysqld_safe Logging to '/data/mysql/data/localhost. localdomain. err '.
151110 02:46:08 mysqld_safe Starting mysqld daemon with databases from/data/mysql/data


Open another terminal (p.s. If you are logging on through ssh, create another ssh connection) and perform the following operations:


# Mysql-u root mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with-


Welcome to the MySQL monitor. Commands end with; or \ g.
Your MySQL connection id is 2
Server version: 5.7.13 MySQL Community Server (GPL)
Copyright (c) 2000,201 5, 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> use mysql;
Database changed
Mysql> UPDATE user SET password = PASSWORD ('000000') WHERE user = 'root ';
ERROR 1054 (42S22): Unknown column 'Password' in 'field list'
Mysql> update user set authentication_string = PASSWORD ('20140901') where user = 'root ';
Query OK, 1 row affected, 1 warning (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 1


Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


Mysql> \ s
Mysql Ver 14.14 Distrib 5.7.13, for linux-glibc2.5 (x86_64) using EditLine wrapper


Connection id: 62
Current database:
Current user: root @ localhost
SSL: Not in use
Current pager: stdout
Using outfile :''
Using delimiter :;
Server version: 5.7.13-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: utf8
Db characterset: utf8
Client characterset: utf8
Conn. characterset: utf8
UNIX socket:/data/AEData/mysql/data/mysql. sock
Uptime: 46 min 54 sec


Threads: 6 Questions: 6846 Slow queries: 0 Opens: 257 Flush tables: 1 Open tables: 201 Queries per second avg: 2.432
--------------


Mysql>
At this point, set the mysql user root password and ensure that the mysql connector set is utf8. Note that the password field in the new mysql. user table is authentication_string.


MySQL remote authorization
The format is as follows:
Mysql> grant all [privileges] on db_name.table_name to 'username' @ 'host' identified by 'Password ';
Example:


Mysql> grant all privileges on *. * to 'root' @ '% 'identified by '123 ';
Query OK, 0 rows affected, 1 warning (0.04 sec)


Mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Mysql>
Or use
Mysql> grant all on *. * to 'root' @ '%' identified by '123 ';

At this point, mysql installation and configuration have been completed !!!

Attached configuration file:
[Client]
Loose_default-character-set = utf8
[Mysqld]
Basedir =/usr/local/mysql
Datadir =/data/mysql/data
Port = 3306
Server_id = 1
Socket =/data/mysql. sock
Expire_logs_days = 7
Innodb_file_per_table
Innodb_buffer_pool_size = 2G
Innodb_thread_concurrency = 24
Innodb_flush_log_at_trx_commit = 1
Innodb_log_buffer_size = 32 M
Innodb_log_file_size = 256 M
Innodb_log_files_in_group = 3
Innodb_max_dirty_pages_pct = 90
Innodb_lock_wait_timeout = 120
Wait_timeout = 60
Interactive_timeout = 7200
Skip-name-resolve
Character-set-server = utf8
Back_log = 50
Max_connections = 3000
Max_connect_errors = 32
Max_allowed_packet = 32 M
Binlog_cache_size = 8 M
Max_heap_table_size = 512 M
Tmp_table_size = 64 M
Key_buffer_size = 16 M
Read_buffer_size = 2 M
Read_rnd_buffer_size = 8 M
Bulk_insert_buffer_size = 64 M
Sort_buffer_size = 4 M
Join_buffer_size = 2 M
Thread_cache_size = 64
Thread_stack = 192 K
Query_cache_type = 1
Query_cache_size = 256 M
Query_cache_limit = 2 M
Ft_min_word_len = 2
Default_storage_engine = INNODB
# Default_table_type = INNODB
Transaction_isolation = REPEATABLE-READ
Lower_case_table_names = 1
# Log_slow_queries
Slow_query_log
Long_query_time = 2
Log-short-format
Myisam_sort_buffer_size = 128 M
Myisam_max_sort_file_size = 10G
Myisam_repair_threads = 1
[Mysqldump]
Quick
Max_allowed_packet = 32 M
Routines
Single-transaction
Hex-blob
Skip-comments
Complete-insert
Skip-disable-keys
Skip-add-locks
Skip-lock-tables
[Isamchk]
Key_buffer = 512 M
Sort_buffer_size = 512 M
Read_buffer = 8 M
Write_buffer = 8 M
[Myisamchk]
Key_buffer = 512 M
Sort_buffer_size = 512 M
Read_buffer = 8 M
Write_buffer = 8 M
[Mysqlhotcopy]
Interactive-timeout
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# Join_buffer_size = 128 M
# Sort_buffer_size = 2 M
# Read_rnd_buffer_size = 2 M
SQL _mode = NO_ENGINE_SUBSTITUTION, STRICT_TRANS_TABLES

Related Article

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.