Centos7.3 detailed tutorial on installing mysql5.7.18 and centos building ss

Source: Internet
Author: User
Tags gpg

Centos7.3 detailed tutorial on installing mysql5.7.18 and centos building ss

1. view the Linux release version

[Root @ typecodes ~] # Cat/etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2. Download the official MySQL Yum Repository

Get Yum Repository from the mysql official (http://dev.mysql.com/downloads/repo/yum/) according to the Linux release (both CentOS and Fedora are in red hat.

[Root @ typecodes ~] # Wget-I http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm--2016-02-03 18:36:02 -- http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpmResolving dev.mysql.com (dev.mysql.com )... 137.254.60.11Connecting to dev.mysql.com (dev.mysql.com) | 137.254.60.11 |: 80... connected. HTTP request sent, awaiting response... 302 FoundLocation: http://repo.mysql.com//mysql57-community-re Lease-el7-7.noarch.rpm [following] -- 18:36:04 -- http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpmResolving repo.mysql.com (repo.mysql.com )... 104.102.164.25Connecting to repo.mysql.com (repo.mysql.com) | 104.102.164.25 |: 80... connected. HTTP request sent, awaiting response... 200 OKLength: 8984 (8.8 K) [application/x-redhat-package-manager] Saving to: 'mysql57-community-releas E-el7-7.noarch.rpm '100% [= ========================================================== ========================================================== ========>] 8,984 --. -K/s in 0s2016-02-03 18:36:07 (68.4 MB/s)-'mysql57-community-release-el7-7.noarch.rpm 'saved [8984/8984] 3 install MySQL's Yum Repository after installing MySQL's Yum Repository, each execution of yum update checks whether MySQL is updated. [Root @ typecodes ~] # Yum-y install mysql57-community-release-el7-7.noarch.rpmLoaded plugins: axelget, fastestmirror, langpacksExamining mysql57-community-release-el7-7.noarch.rpm: mysql57-community-release-el7-7.noarchMarking mysql57-community-release-el7-7.noarch.rpm to be installedResolving Dependencies --> Running transaction check ---> Package mysql57-community-release.noarch 0: el7-7 will be installed --> Finished Dependency ResolutionDependencies Resolved ====================================== ========================================================== ========================================================== ========================================================== ========= Package Arch Version Repository Size ======================== ========================================================== ========================================================== ========================================================== ========== =============== Installing: mysql57-community-release noarch el7-7/mysql57-community-release-el7-7.noarch 7.8 kTransaction Summary ================================ ========================================================== ========================================================== ========================================================== ================== Install 1 PackageTotal size: 7.8 kInstalled size: 7.8 kDownloading packages: Running transaction checkRunn Ing transaction testTransaction test succeededRunning transaction Installing: mysql57-community-release-el7-7.noarch 1/1 Verifying: mysql57-community-release-el7-7.noarch 1/1 Installed: mysql57-community-release.noarch 0: el7-7Complete!

3. Install the MySQL database server version

[root@typecodes ~]# yum -y install mysql-community-serverLoaded plugins: axelget, fastestmirror, langpacksNo metadata available for baseNo metadata available for epelNo metadata available for extrasrepomd.xml                                  | 2.5 kB 00:00:00  update mysql-connectors-community metadata successfullyrepomd.xml                                  | 2.5 kB 00:00:00  update mysql-tools-community metadata successfullyrepomd.xml                                  | 2.5 kB 00:00:00  update mysql57-community metadata successfullyNo metadata available for updatesmysql-connectors-community                              | 2.5 kB 00:00:00  mysql-tools-community                               | 2.5 kB 00:00:00  mysql57-community                                | 2.5 kB 00:00:00  (1/3): mysql-tools-community/x86_64/primary_db                         | 24 kB 00:00:01  (2/3): mysql57-community/x86_64/primary_db                          | 28 kB 00:00:01  (3/3): mysql-connectors-community/x86_64/primary_db                        | 8.6 kB 00:00:02  Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * epel: mirrors.neusoft.edu.cn * extras: mirrors.163.com * updates: mirrors.163.comResolving Dependencies--> Running transaction check---> Package mysql-community-server.x86_64 0:5.7.10-1.el7 will be installed--> Processing Dependency: mysql-community-common(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64--> Processing Dependency: mysql-community-client(x86-64) = 5.7.10-1.el7 for package: mysql-community-server-5.7.10-1.el7.x86_64--> Running transaction check---> Package mysql-community-client.x86_64 0:5.7.10-1.el7 will be installed--> Processing Dependency: mysql-community-libs(x86-64) = 5.7.10-1.el7 for package: mysql-community-client-5.7.10-1.el7.x86_64---> Package mysql-community-common.x86_64 0:5.7.10-1.el7 will be installed--> Running transaction check---> Package mariadb-libs.x86_64 1:5.5.44-2.el7.centos will be obsoleted--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-6.el7.x86_64---> Package mysql-community-libs.x86_64 0:5.7.10-1.el7 will be obsoleting--> Running transaction check---> Package mysql-community-libs-compat.x86_64 0:5.7.10-1.el7 will be obsoleting--> Finished Dependency ResolutionDependencies Resolved======================================================================================================================================================================= Package           Arch       Version        Repository        Size=======================================================================================================================================================================Installing: mysql-community-libs        x86_64      5.7.10-1.el7       mysql57-community      2.2 M  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-libs-compat      x86_64      5.7.10-1.el7       mysql57-community      2.0 M  replacing mariadb-libs.x86_64 1:5.5.44-2.el7.centos mysql-community-server        x86_64      5.7.10-1.el7       mysql57-community      142 MInstalling for dependencies: mysql-community-client        x86_64      5.7.10-1.el7       mysql57-community       24 M mysql-community-common        x86_64      5.7.10-1.el7       mysql57-community      269 kTransaction Summary=======================================================================================================================================================================Install 3 Packages (+2 Dependent packages)Total download size: 171 MDownloading packages:mysql-community-server-5.7.10-1.el7.x86_64.rpm                         | 142 MB 00:03:42  mysql-community-libs-compat-5.7.10-1.el7.x86_64.rpm                        | 2.0 MB 00:00:03  mysql-community-libs-5.7.10-1.el7.x86_64.rpm                         | 2.2 MB 00:00:05  mysql-community-client-5.7.10-1.el7.x86_64.rpm                         | 24 MB 00:00:41  warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-common-5.7.10-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY00 ETA Public key for mysql-community-common-5.7.10-1.el7.x86_64.rpm is not installedmysql-community-common-5.7.10-1.el7.x86_64.rpm                         | 269 kB 00:00:01  Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysqlImporting GPG key 0x5072E1F5: Userid  : "MySQL Release Engineering <mysql-build@oss.oracle.com>" Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql57-community-release-el7-7.noarch (@/mysql57-community-release-el7-7.noarch) From  : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysqlRunning transaction checkRunning transaction testTransaction test succeededRunning transaction Installing : mysql-community-common-5.7.10-1.el7.x86_64                           1/6  Installing : mysql-community-libs-5.7.10-1.el7.x86_64                           2/6  Installing : mysql-community-client-5.7.10-1.el7.x86_64                           3/6  Installing : mysql-community-server-5.7.10-1.el7.x86_64                           4/6  Installing : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          5/6  Erasing : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6  Verifying : mysql-community-server-5.7.10-1.el7.x86_64                           1/6  Verifying : mysql-community-libs-compat-5.7.10-1.el7.x86_64                          2/6  Verifying : mysql-community-common-5.7.10-1.el7.x86_64                           3/6  Verifying : mysql-community-libs-5.7.10-1.el7.x86_64                           4/6  Verifying : mysql-community-client-5.7.10-1.el7.x86_64                           5/6  Verifying : 1:mariadb-libs-5.5.44-2.el7.centos.x86_64                           6/6Installed: mysql-community-libs.x86_64 0:5.7.10-1.el7   mysql-community-libs-compat.x86_64 0:5.7.10-1.el7   mysql-community-server.x86_64 0:5.7.10-1.el7Dependency Installed: mysql-community-client.x86_64 0:5.7.10-1.el7          mysql-community-common.x86_64 0:5.7.10-1.el7Replaced: mariadb-libs.x86_64 1:5.5.44-2.el7.centosComplete![root@typecodes ~]# clear

Last:

4. Start the database:

[root@typecodes ~]# systemctl start mysqld.service

Then use the commandsystemctl status mysqld.serviceView the service status after the MySQL database is started:

5. Get the initial password

After MySQL is installed and started using YUM, the MySQL process automatically prints the initial password of the root user in the process log:

####### Obtain the initial password of the root user from the mysql process log: ra % yk7urCBIh [root @ typecodes ~] # Grep "password"/var/log/mysqld. log2016-02-03T10: 42: 17.272166Z 1 [Note] A temporary password is generated for root @ localhost: ra % yk7urCBIh2016-02-03T10: 42: 36.776875Z 2 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 42: 52.063138Z 3 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 42: 57.564373Z 4 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 43: 01.477007Z 5 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 46: 03.642008Z 6 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 46: 11.217889Z 7 [Note] Access denied for user 'root' @ 'localhost' (using password: NO) 2016-02-03T10: 47: 44.755199Z 0 [Note] Shutting down plugin 'validate _ password' 2016-02-03T10: 47: 46.505844Z 0 [Note] Shutting down plugin 'sha256 _ password' 2016-02-03T10: 47: 46.505851Z 0 [Note] Shutting down plugin 'mysql _ native_password'

6. Change the root user password

Use the initial password of the root user obtained in section 5 and modify it:

set global validate_password_policy =0; // The default value is 1, that is, MEDIUM. Therefore, the initial password must conform to the length and contain numbers, lowercase letters or uppercase letters, and special characters.

Set global validate_password_length = 4; // specify the length of data in the password. alter user root @ localhost identified by 'crow'; // modify the password

Add Remote Access Permissions

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'crow' WITH GRANT OPTION;FLUSH PRIVILEGES;

Log out of mysql and restart the service.

systemctl restart mysqld

Firewall opens port 3306

firewall-cmd --zone=public --add-port=3306/tcp --permanent

Restart Firewall

Firewall-cmd -- reload [root @ typecodes ~] # Mysql-uroot-pEnter password: ###### enter the default root password and press ENTER Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 2 Server version: 5.7.10Copyright (c) 2000,201 5, 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> alter user 'root' @ 'localhost' identified by 'new password'; Query OK, 0 rows affected (0.00 sec) mysql> exitBye

7. Installation Complete

So far, MySQL 5.7.10 has been installed using the YUM method in CentOS7. As shown in the following figure, you can use the new root password to log on to MySQL.

[root@typecodes ~]# mysql -uroot -ppasswordmysql: [Warning] Using a password on the command line interface can be insecure.Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.7.10 MySQL Community Server (GPL)Copyright (c) 2000, 2015, 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> use mysql;Reading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show databases;+--------------------+| Database   |+--------------------+| information_schema || mysql    || performance_schema || sys    |+--------------------+4 rows in set (0.00 sec)mysql> clearmysql> exitBye[root@typecodes ~]# clear

Appendix 1: view the configuration information of the MySQL database

The MySQL configuration file is still/etc/my. cnf. You can run the mysql_config command to view other installation information. The dynamic library files are stored in the/usr/lib64/mysql directory.

Appendix 2: For C/C ++ and other developers

To use header files such as mysql. h, run the following command to install the mysql development version.

[root@typecodes ~]# yum -y install mysql-community-devel

Appendix 3: delete MySQL Repository

Because MySQL's Yum Repository is installed in section 3, the update will be checked every time the yum operation is executed. To remove this automatic check operation, run the following command to uninstall MySQL Repository.

[root@typecodes ~]# yum -y remove mysql57-community-release-el7-7.noarchupdate 2017.04.10 11:10

You can also use the yum method above to install the latest mysql version mysql 5.7.18 on the mysql official website. You only need to replace the version of the rmp package in section 2, and the subsequent steps remain unchanged.

wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm

The above is a detailed tutorial on installing mysql5.7.18 on centos7.3. I hope it will help you. If you have any questions, please leave a message and I will reply to you in time. Thank you very much for your support for the help House website!

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.