1. Download mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz from the website
After testing, this article also applies to the following version:
Mysql-5.7.10-linux-glibc2.5-x86_64.tar.gz
Mysql-5.7.11-linux-glibc2.5-x86_64.tar.gz
Mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz
Mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz
Official website: http://dev.mysql.com/downloads/mysql/
2. Check if you have installed MySQL under Linux, no uninstall clean
#rpm-qa|grep-i MySQL
mysql-5.7.13-linux-glibc2.5-x86_64
* Visible already has the library file installed, should uninstall first, otherwise will appear overwrite error. Note unload: The--NODEPS option is used when loading, ignoring dependencies:
#rpm-E mysql-5.7.13-linux-glibc2.5-x86_64--nodeps
Of course, you may also have more than this one file, there may be more than one, then you are sequentially rpm-e xx--nodeps Uninstall, uninstall the finished check again, if the removal of clean, after the following steps.
3. Create MySQL user group/user, data directory and its user directory
Before this step must make sure that you build the user and the user group does not exist, or in the process of the subsequent error, delete the user to delete the user group name before deleting.
# userdel MySQL # Delete user
# groupdel MySQL # Delete user group name
# mkdir/home/mysql # Create a folder under the home folder MySQL
# mkdir/home/mysql /data # Create folders under MySQL folder data
# groupadd MySQL # Create a user group named MySQL
# useradd-g mysql-d/home/mysql MySQL # Create a user under a user group
4, unzip the installation package and the contents of the unpacked package copy to the MySQL installation directory/home/mysql
# TAR-XZVF Mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz # Extract Files
# cd mysql-5.7.13-linux-glibc2.5-x86_64 # enter
# MV */home/mysql # moved to the MySQL folder I created before.
5. Initialize MySQL database
# Cd/home/mysql # into the installation directory
#/bin/mysql_install_db--user=mysql--basedir=/home/mysql--datadir=/home/mysql/data
[WARNING] mysql_install_db is deprecated. Please consider switching to mysqld--initialize 2015-11-10 02:09:23
[WARNING] The bootstrap log isn ' t empty:2015-11- 02:09:23
[WARNING] 2015-11-10t10:09:18.114182z 0
[WARNING]--bootstrap is deprecated. Please consider using--initialize instead 2015-11-10t10:09:18.129343z 0
[Warning] Changed limits:max_open_files: 1024 (requested 5000) 2015-11-10t10:09:18.129408z 0
[Warning] Changed limits:table_open_cache:431 (requested 2000)
mysql5.7 new features: From the above can be seen, mysql_install_db is no longer recommended to use, the proposed change to MYSQLD--initialize completed instance initialization.
#./bin/mysqld--user=mysql--basedir=/home/mysql--datadir=/home/mysql/data--initialize
#/mysqld--user=mysql --basedir=/home/mysql--datadir=/home/mysql/data--initialize
[Warning] TIMESTAMP with implicit DEFAULT value is Deprecated. Please use--explicit_defaults_for_timestamp server option (the documentation for more details).
[ERROR]--initialize specified but the data directory has files in it. Aborting. 2016-04-08t01:46:53.155879z 0
[ERROR] Aborting
The above error occurred because we did not empty the MySQL data directory and execute the purge command as follows:
# cd/home/mysql/data # into the installation directory in the data directory # RM-FR * # empty data # cd/home/mysql #./bin/mysqld --user=mysql--basedir=/home/mysql--datadir=/home/mysql/data--initialize [Warning] TIMESTAMP with implicit DEFAULT Value is deprecated. Please use--explicit_defaults_for_timestamp server option (the documentation for more details). 2016-04-08t01:47:59.945537z 0 [Warning] innodb:new log files created, lsn=45790 2016-04-08t01:48:00.333528z 0 [Warning] I Nnodb:creating FOREIGN KEY constraint system tables. 2016-04-08t01:48:00.434908z 0 [Warning] No existing UUID has been found, so we assume s server has been started. Generating a new uuid:ece26421-fd2b-11e5-a1e3-00163e001e5c. 2016-04-08t01:48:00.440125z 0 [Warning] gtid the table isn't ready to be used. Table ' mysql.gtid_executed ' cannot be opened. 2016-04-08t01:48:00.440904z 1 [note] A temporary password are generated for root@localhost: **MJT, #x_5sW
Keep in mind the random password above, as above **mjt, #x_5sW, we need to modify the password below.
6, detect whether the MySQL service can be started
# cd/home/mysql
#/support-files/mysql.server start
starting MySQL. Ok!
This is the normal case.
I just used the/home/mysql for MySQL installation directory basedir, 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 di Rectory
Starting MySQL error! Couldn ' t find MySQL server (/usr/local/mysql/bin/mysqld_safe)
The default installation directory for the MySQL tar.gz installation package is/usr/local/mysql, which we need to modify/support-files/ The Basedir and DataDir directory paths for mysql.server files are the basedir and datadir paths of the MySQL where our environment is located, as follows:
# vim Support-files/mysql.server
--------------------------
...
Basedir=/home/mysql
datadir=/home/mysql/data ...
--------------------------
#./support-files/mysql.server
start starting MySQL. Ok!
Note: The above basedir and datadir parts are manually changed, then how to manually change in the command, step
1, press the keyboard I key (insert), and then you can write in the location you want.
2, Edit finished exit, Esc key.
3, Shift key plus: (colon key) exit edit.
4, wq! Save edits
7. Create Soft Links
# ln-s/home/mysql/bin/mysql/usr/bin/mysql
8. Create configuration file
There may be an error in the first 3 steps below, and if there is a mistake, skip it because the environment of different computers is not the same.
1, the default generated MY.CNF backup
# Mv/etc/my.cnf/etc/my.cnf.bak
If this step error, no relationship, under normal circumstances is due to the/ect folder without MY.CNF lock caused, create it, or you will not create, directly using VIM/ECT/MY.CNF command edit,
And then directly exit the editor can, in the execution of this command will not be wrong, exit the Edit command ESC key-> (SHIFT key +: (colon key)-> wq!), and then execute the above command will not be an error.
2, access to MySQL installation directory support Files directory
# Cd/home/mysql/support-files
3, copy profile template for the new MySQL configuration file,
# CP MY-DEFAULT.CNF/ETC/MY.CNF
4, set the code, you can modify the new configuration file options, do not modify the configuration options, MySQL is the default configuration parameters run.
The following is I modify the configuration file/etc/my.cnf, set the encoding to UTF8 to prevent garbled
# vim/etc/my.cnf
[mysqld]
basedir =/home/mysql
datadir =/home/mysql/data
character_set_server= UTF8
init_connect= ' SET NAMES UTF8 '
[client]
Default-character-set=utf8
Sometimes use this command, the first 3 steps have problems here may my.cnf file is empty, this does not matter, since there is no generation, then you edit it yourself! How the specific edits are implemented is referred to step 6.
9, configure the MySQL service boot automatically start
# cp/home/mysql/support-files/mysql.server/etc/init.d/mysqld # Copy boot file to/etc/init.d/and command to mysqld
# chmod 755/etc/ Init.d/mysqld # Increase execution Permissions
# chkconfig--list mysqld # Check for no mysqld in the list of boot entries
# chkconfig--add # if not, add mysqld c4/># chkconfig mysqld on # Set the boot up with this command:
If the error occurs in the first step, you have just configured the problem in step 8th, so you reset
After you finish this step, do the next operation again.
If the following problems occur in the subsequent operation
This is the problem of the computer environment, you can directly
10, MySQL service start/restart/stop
# service mysqld Start # services
mysqld Restart # service # services
mysqld Stop # Stop service
11, initialization of the MySQL user root password
# cd/home/mysql #/bin/mysqladmin-u root-p ' **mjt, #x_5sW ' password ' 123456 ' mysqladmin: # Just before the initial password [Warning] Using A
Password on the command line interface can be insecure.
Warning:since password would be sent to server in plain text with the use of SSL connection to ensure password. mysql> use MySQL Database changed mysql> update user set authentication_string = PASSWORD (' 123456 ') where user = ' ro
OT '; Query OK, 0 rows affected, 1 Warning (0.00 sec) rows Matched:2 changed:0 warnings:1 mysql> \s--------------MySQL V Er 14.14 distrib 5.7.13, for linux-glibc2.5 (x86_64) using Editline wrapper Connection id:3 current Database:mysql Curre
NT User:root@localhost Ssl:not in use the current pager:stdout using outfile: ' Using delimiter:; Server version:5.7.13 MySQL Community Server (GPL) Protocol version:10 connection:localhost via UNIX socket server Char Acterset:utf8 Db Characterset:utf8 Client characterset:utf8 Conn. Characterset:utf8 UNIX Socket:/tmp/mysql.sock UptiMe:1 hour sec threads:1 questions:50 slow queries:0 opens:136 Flush tables:1 Open tables:129 queries per Second avg:0.009--------------
If this step is not complete, that is, you can not modify the password, you may also direct the following way to log in first
But if you do not change the password, do not enter the trouble every time and do some operations will be reported errors
Must reset your password using ALTER USER statement before executing this statement # means you have to reset your password before performing this execute operation
Here we teach you to change the password in a different way, which is executed in sequence when it is already logged in.
mysql> SET PASSWORD = PASSWORD (' 123456 '); # PASSWORD () 123456 is the new password I set, you can also set your password to
Query OK, 0 rows affected, 1 Warning (0.00 sec)
rows Matched:2 Changed : 0 warnings:1
mysql> ALTER USER ' root ' @ ' localhost ' PASSWORD EXPIRE NEVER;
Query OK, 0 rows affected, 1 Warning (0.00 sec)
rows matched:2 changed:0 warnings:1 mysql> flush Privileges
;
Query OK, 0 rows affected, 1 Warning (0.00 sec)
Rows matched:2 changed:0 warnings:1
MySQL Remote licensing
[Root@testfornss ~]# mysql-u root-p
Enter Password:
Welcome to the MySQL monitor. Commands End With; or \g.
Your MySQL Connection ID is 4
server version:5.7.13 mysql Community Server (GPL)
Copyright (c), 2016, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark to Oracle Corporation and/or its
affiliates. The other names may is trademarks of their respective
owners.
Type ' help, ' or ' \h ' for help. Type ' \c ' to clear the current input statement.
Mysql> grant all privileges in *.* to ' root ' @ '% ' identified by ' 123456 ';
Query OK, 0 rows affected, 1 Warning (0.00 sec)
mysql>
Or:
Grant all on *.* to ' root ' @ '% ' identified by ' 123456 ';
If you do not set up a remote connection, use the MySQL database connection tool is not connected to the Oh!!!
13. Use the database Connection tool to test if your installation has been successful
The first thing to know is that the IP of the remote connected Linux system ensures that the computer can be reconnected if it is already able to ping.
The above is a small set to introduce the CentOS 6.5 installed MySQL 5.7.16 Linux glibc2.5 x86 64, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!