Install Mysql5.7 on CentOS7 (decompress Version)

Source: Internet
Author: User
Tags localhost mysql

Install Mysql5.7 on CentOS7 (decompress Version)

#### 1. Download the installation package
Http://dev.mysql.com/downloads/mysql/#downloads
We recommend that you download the TAR package of the general installation method.

2. Check whether the library file exists. If yes, delete it.
[root@localhost Desktop]$ rpm -qa | grep mysqlmysql-libs-5.1.52-1.el6_0.1.x86_64[root@localhost ~]$ rpm -e mysql-libs-5.1.52.x86_64 --nodeps[root@localhost ~]$
3. Check whether the mysql group and user exists, if not created.
[root@localhost ~]$ cat /etc/group | grep mysqlmysql:x:490:[root@localhost ~]$ cat /etc/passwd | grep mysqlmysql:x:496:490::/home/mysql:/bin/bash

If none of the above conditions exist by default, execute the Add command:

[Root @ localhost ~] $ Groupadd mysql [root @ localhost ~] $ Useradd-r-g mysql // The useradd-r parameter indicates that the mysql user is a system user and cannot be used to log on to the system.
4. decompress the TAR package and change the group and user
[root@localhost ~]$ cd /usr/local/[root@localhost local]$ tar xvf mysql-5.7.12-linux-glibc2.5-x86_64.tar[root@localhost local]$ ls -ltotal 1306432-rwxr--r--. 1 root root  668866560 Jun  1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz-rw-r--r--. 1 7161 wheel  29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gz[root@localhost local]$ tar xvfz mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz[root@localhost local]$ mv mysql-5.7.12-linux-glibc2.5-x86_64 mysql[root@localhost local]$ ls -ltotal 1306436drwxr-xr-x. 2 root root       4096 Dec  4  2009 bindrwxr-xr-x. 2 root root       4096 Dec  4  2009 etcdrwxr-xr-x. 2 root root       4096 Dec  4  2009 gamesdrwxr-xr-x. 2 root root       4096 Dec  4  2009 includedrwxr-xr-x. 2 root root       4096 Dec  4  2009 libdrwxr-xr-x. 3 root root       4096 Dec  2 14:36 lib64drwxr-xr-x. 2 root root       4096 Dec  4  2009 libexecdrwxr-xr-x. 9 7161 wheel      4096 Mar 28 12:51 mysql-rwxr--r--. 1 root root  668866560 Jun  1 15:07 mysql-5.7.12-linux-glibc2.5-x86_64.tar-rw-r--r--. 1 7161 wheel 638960236 Mar 28 12:54 mysql-5.7.12-linux-glibc2.5-x86_64.tar.gz-rw-r--r--. 1 7161 wheel  29903372 Mar 28 12:48 mysql-test-5.7.12-linux-glibc2.5-x86_64.tar.gzdrwxr-xr-x. 2 root root       4096 Dec  4  2009 sbindrwxr-xr-x. 6 root root       4096 Dec  2 14:36 sharedrwxr-xr-x. 2 root root       4096 Dec  4  2009 src[root@localhost local]$ chown -R mysql mysql/[root@localhost local]$ chgrp -R mysql mysql/[root@localhost local]$ cd mysql/
5. Install and initialize the database
[root@localhost mysql]$ bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/2016-06-01 15:23:25 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize2016-06-01 15:23:30 [WARNING] The bootstrap log isn't empty:2016-06-01 15:23:30 [WARNING] 2016-06-01T22:23:25.491840Z 0 [Warning] --bootstrap is deprecated. Please consider using --initialize instead2016-06-01T22:23:25.492256Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)2016-06-01T22:23:25.492260Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)

If you change the default installation path, 1)/etc/my. cnf,/etc/init. d/modify basedir = '/apps/mysql' datadir ='/apps/mysql/data' in mysqld. 2) create ln mkdir-p/usr/local/mysql/bin ln-s/apps/mysql/bin/mysqld/usr/local/mysql/bin/mysqld

[root@localhost mysql]$[root@localhost mysql]$ cp -a ./support-files/my-default.cnf /etc/my.cnf[root@localhost mysql]$ cp -a ./support-files/mysql.server  /etc/init.d/mysqld
[root@localhost mysql]$ cd bin/[root@localhost bin]# ./mysqld_safe --user=mysql &[1] 2932[root@localhost bin]# 2016-06-01T22:27:09.708557Z mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.2016-06-01T22:27:09.854913Z mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[Root @ localhost bin] #/etc/init. d/mysqld restartShutting down MySQL .. 2016-06-01T22: 27: 50.498694Z mysqld_safe mysqld from pid file/usr/local/mysql/data/localhost. localdomain. pid ended SUCCESS! Starting MySQL. SUCCESS! [1] + Done. /mysqld_safe -- user = mysql [root @ localhost bin] $ // set boot start [root @ localhost bin] $ chkconfig -- level 35 mysqld on [root @ localhost bin] $
6. initialize the password

Mysql5.7 generates an initialization password, but you do not need to log on to mysql5.7 for the first time in a previous version.

[root@localhost bin]$ cat /root/.mysql_secret # Password set for user 'root@localhost' at 2016-06-01 15:23:25 ,xxxxxR5H9[root@localhost bin]$./mysql -uroot -pEnter password: Welcome to the MySQL monitor.  Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.7.12Copyright (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> SET PASSWORD = PASSWORD('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
7. Add Remote Access Permissions
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> update user set host = '%' where user = 'root '; query OK, 1 row affected (0.00 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> select host, user from user; + ----------- + | host | user | + ----------- + | % | root | localhost | mysql. sys | + ----------- + // restart to take effect/etc/init. d/mysqld restart

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.