Install mysql 5.7.16 linux glibc2.5 x86 64 (recommended) and centos5.7.16 in CentOS 6.5

Source: Internet
Author: User
Tags ssl connection

Install mysql 5.7.16 linux glibc2.5 x86 64 (recommended) and centos5.7.16 in CentOS 6.5

1. Download mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz from official website

Tested, this article also applies to the following versions:

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 whether you have installed mysql in Linux and have not uninstalled it clean.

#rpm -qa|grep -i mysqlmysql-5.7.13-linux-glibc2.5-x86_64

* It can be seen that the library file has been installed and should be uninstalled first. Otherwise, a overwriting error will occur. Note: The -- nodeps option is used for loading, and dependency is ignored:

#rpm -e mysql-5.7.13-linux-glibc2.5-x86_64 --nodeps

Of course, you may have more than one file, or multiple files, so you can unmount rpm-e xx -- nodeps in sequence. After uninstalling the file, check again. If you are sure to delete the file, follow the steps below.

3. Create a user group/user, data directory, and user directory for mysql.

Before this step, make sure that the user you created and the user group do not exist. Otherwise, an error will be reported during the subsequent process. Delete the user before deleting the user group name.

# Userdel mysql # delete user # groupdel mysql # delete user group name # mkdir/home/mysql # create a folder mysql # mkdir/home/mysql/data # In the mysql folder create a folder data # groupadd mysql # create a user group named mysql # useradd-g mysql-d/home/mysql # create a user under the user group

4. Unzip the installation package and copy the content in the package to the installation directory/home/mysql of mysql.

# Tar-xzvf mysql-5.7.13-linux-glibc2.5-x86_64.tar.gz # unzip the file # cd mysql-5.7.13-linux-glibc2.5-x86_64 # Enter # mv */home/mysql # Move to the mysql folder I created earlier.

5. initialize the mysql database

# Cd/home/mysql # enter 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 02:09:23 [WARNING] The bootstrap log isn't empty: 02:09:23 [WARNING] 2015-11-10T10: 09: 18.114182Z 0 [Warning] -- bootstrap is deprecated. please consider using -- initialize instead 2015-11-10T10: 09: Drawing 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000) 2015-11-10T10: 09: Drawing 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

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.

# ./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 (see 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 occurs because the mysql data DIRECTORY is not cleared. Execute the clear command as follows:

# Cd/home/mysql/data # enter the data directory under the installation directory # rm-fr * # Clear 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 (see 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] InnoDB: Creating foreign key constraint system tables. 2016-04-08T01: 48: 00.434908Z 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: ece26421-fd2b-11e5-a1e3-00163e001e5c. 2016-04-08T01: 48: 00.0000125z 0 [Warning] Gtid table is not ready to be used. table 'mysql. gtid_executed 'cannot be opened. 2016-04-08T01: 48: 00.20.904z 1 [Note] A temporary password is generated for root @ localhost: ** mjT, # x_5sW

Keep in mind the above random password, as shown above ** mjT, # x_5sW. We will use it when changing the password below.

6. Check whether the mysql service can be started.

# cd /home/mysql# ./support-files/mysql.server startStarting MySQL.. OK!

This is normal.

I just used the/home/mysql installation directory basedir for mysql. 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 directoryStarting MySQL ERROR! Couldn't find MySQL server (/usr/local/mysql/bin/mysqld_safe)

The default installation directory of the tar.gz installation package of mysqlis/usr/local/mysql. At this time, we need to modify/support-files/mysql. the basedir and datadir directory paths of the server File are the basedir and datadir paths of mysql in the environment, as shown below:

# vim support-files/mysql.server--------------------------...basedir=/home/mysqldatadir=/home/mysql/data...--------------------------# ./support-files/mysql.serverstart Starting MySQL.. OK!

Note: The basedir and datadir sections above are manually modified, so how to manually modify them in the command

1. Press the I key (insert) on the keyboard, and then you can write it at the position you want.

2. Exit after editing. Press esc.

3. Shift + (colon) to exit the editing.

4. wq! Save and edit

7. Create soft links

# ln -s /home/mysql/bin/mysql /usr/bin/mysql

8. Create a configuration file

During the following three steps, errors may occur. If there are any errors, skip this step because the environments of different computers are different,

1. Back up the default my. cnf File

# mv /etc/my.cnf /etc/my.cnf.bak

If this step reports an error, it does not matter. Normally, it is because the/ect Folder does not have my. if the cnf lock is caused, you can create it once, or you will not create it. Use vim/ect/my directly. edit the cnf command,
Then you can exit the editing directly. When you execute this command, no errors will occur. Exit the editing command esc key-> (shift Key + :( colon key)-> wq! ), And then the above command will not report an error.

2. Enter the mysql installation directory support file directory

# cd /home/mysql/support-files

3. Copy the configuration file template to the new mysql configuration file,

# cp my-default.cnf /etc/my.cnf

4. Set the encoding. You can modify the new configuration file options as needed. If you do not modify the configuration options, mysql runs based on the default configuration parameters.

The following is how to modify the configuration file/etc/my. cnf and set the encoding to utf8 to prevent garbled characters:

# vim /etc/my.cnf[mysqld]basedir = /home/mysqldatadir = /home/mysql/datacharacter_set_server=utf8init_connect='SET NAMES utf8'[client]default-character-set=utf8

Sometimes, after using this command, if there is a problem in the first three steps, the my. cnf file may be empty. It doesn't matter. Since it is not generated, You can edit it yourself! For details about how to implement the editing, refer to Step 6.

9. Configure the mysql service to start automatically upon startup

# Cp/home/mysql/support-files/mysql. server/etc/init. d/mysqld # copy the Startup File to/etc/init. d/run the command mysqld # chmod 755/etc/init again. d/mysqld # add execution permission # chkconfig -- list mysqld # check that the self-startup Item list does not contain mysqld, # chkconfig -- add mysqld # If not, add mysqld: # chkconfig mysqld on # Use this command to set startup:

If an error is reported in step 1, it indicates that the configuration in step 2 has encountered a problem, and you can reset it.

After completing this step, re-execute the above operations

If the following problems occur in subsequent operations

This is a problem with the computer environment.

10. Start, restart, and stop the mysql service.

# Service mysqld start # start service # service mysqld restart # restart service # service mysqld stop # stop service

11. initialize the mysql user root password

# Cd/home/mysql #. /bin/mysqladmin-u root-p '** mjT, # x_5sW 'Password' 100' mysqladmin: # the initial password [Warning] Using a password on the command line interface can be insecure. warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. mysql> use mysqlDatabase changedmysql> update user set authentication_string = PASSWORD ('000000') where user = 'root'; Query OK, 0 rows affected, 1 warning (123456 sec) Rows matched: 2 Changed: 0 Warnings: 1 mysql> \ s -------------- mysql Ver 14.14 Distrib 5.7.13, for linux-glibc2.5 (x86_64) using EditLine wrapperConnection id: 3 Current database: mysqlCurrent user: root @ localhostSSL: not in useCurrent pager: stdoutUsing outfile: ''Using delimiter:; Server version: 5.7.13 MySQL Community Server (GPL) Protocol version: 10 Connection: Localhost via UNIX socketServer characterset: utf8Db characterset: utf8Client characterset: utf8Conn. characterset: utf8UNIX socket:/tmp/mysql. sockUptime: 1 hour 29 min 17 secThreads: 1 Questions: 50 Slow queries: 0 Opens: 136 Flush tables: 1 Open tables: 129 Queries per second avg: 0.009 --------------

If this step cannot be completed, or the password cannot be changed, you can log on

However, if you do not change the password, it will be difficult to log on every time and an error will be reported when you perform some operations.

You must reset your password using alter user statement before executing this statement # It means You must reset your password before executing this execute Operation

Here, you can use another method to change the password, which is executed in sequence when you have logged in.

Mysql> set password = PASSWORD ('000000'); #123456 in PASSWORD () is the new password I set. You can also SET it to your PASSWORD 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

12. mysql remote authorization

[root@testfornss ~]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 4Server version: 5.7.13 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> grant all privileges on *.* 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 remote connection, you cannot use the mysql database connection tool !!!

13. Use a database connection tool to test whether your installation was successful.

First, you must know the ip address of the remote Linux system and ensure that the local machine can be pinged before connection.

The above section describes how to install mysql 5.7.16 linux glibc2.5 x86 64 in CentOS 6.5. If you have any questions, please leave a message, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!

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.