Mysql 5.7.14 installation and configuration code sharing, mysql5.7.14

Source: Internet
Author: User
Tags account security

Mysql 5.7.14 installation and configuration code sharing, mysql5.7.14

This document records the installation and configuration code of mysql 5.7.14, as shown in the following figure.

OS: CentOS 6.6
DB: Mysql 5.7.14

1. Download mysql 

Cd/tools

Wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz

2. Create a directory for extracting MySQL binary files 

mkdir -p /opt/mysql  [root@zw-test-db mysql]# cd /tools/ [root@zw-test-db tools]# ll -l mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz -rw-r--r-- 1 root root 642694570 Aug 29 15:02 mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz 

3. decompress the package to the/opt/mysql directory. 

[root@zw-test-db tools]# cd /opt/mysql/ [root@zw-test-db mysql]# tar -zxvf /tools/mysql-5.7.14-linux-glibc2.5-x86_64.tar.gz [root@zw-test-db mysql]# mv mysql-5.7.14-linux-glibc2.5-x86_64/ mysql-5.7.14 [root@zw-test-db mysql]# ll drwxr-xr-x 9 7161 31415 4096 Jul 12 21:03 mysql-5.7.14 

4. Create a soft connection to/usr/local 

[root@zw-test-db mysql]# cd /usr/local/ [root@zw-test-db local]# ls bin etc games include lib lib64 libexec redis-3.2.2 sbin share src [root@zw-test-db local]# ln -s /opt/mysql/mysql-5.7.14 /usr/local/mysql [root@zw-test-db local]# ll mysql lrwxrwxrwx 1 root root 23 Aug 31 17:36 mysql -> /opt/mysql/mysql-5.7.14 [root@zw-test-db local]# 

5. Create a user 

[root@zw-test-db /]# groupadd mysql [root@zw-test-db /]# useradd -M -g mysql -s /sbin/nologin -d /usr/local/mysql mysql 

-S nologin does not have a shell and cannot be logged on

6. Create a basic directory based on the configuration file 

mkdir /data/mysql mkdir /data/mysql/mysql_3306 cd /data/mysql/mysql_3306/ mkdir data mkdir logs mkdir tmp chown -R mysql:mysql /data/mysql/mysql3306 

7. Create the/etc/my. cnf configuration file (process omitted) 

8. initialization,A default password will be added during initialization of 5.7.

[Root @ zw-test-db mysql] # cd/usr/local/mysql/[root @ zw-test-db mysql] #. /bin/mysqld -- initialize [root @ zw-test-db data] # pwd/data/mysql/mysql_3306/data ### The following is 5.5, 5.6 initialization/usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql

9. view the error log,Check whether there is an error.

cd /data/mysql/mysql_3306/data [root@zw-test-db data]# vim error.log [root@zw-test-db data]# tail -f error.log 2016-08-31T09:44:32.394657Z 0 [Note] Giving 0 client threads a chance to die gracefully 2016-08-31T09:44:32.394680Z 0 [Note] Shutting down slave threads 2016-08-31T09:44:32.394686Z 0 [Note] Forcefully disconnecting 0 remaining clients 2016-08-31T09:44:32.415409Z 0 [Note] Binlog end 2016-08-31T09:44:32.434217Z 0 [Note] InnoDB: FTS optimize thread exiting.2016-08-31T09:44:32.434293Z 0 [Note] InnoDB: Starting shutdown... 2016-08-31T09:44:32.534587Z 0 [Note] InnoDB: Dumping buffer pool(s) to /data/mysql/mysql_3306/data/ib_buffer_pool 2016-08-31T09:44:32.534741Z 0 [Note] InnoDB: Buffer pool(s) dump completed at 160831 17:44:32 2016-08-31T09:44:34.308784Z 0 [Note] InnoDB: Shutdown completed; log sequence number 2525428 2016-08-31T09:44:34.308945Z 0 [Note] InnoDB: Removed temporary tablespace data file: "ibtmp1" 

10. view the initialization Password 

[Root @ zw-test-db data] # grep password error. log
2016-08-31T09: 44: 21.172167Z 1 [Note] A temporary password is generated for root @ localhost: 8 aahkRkxfm % t

Password: 8 aahkRkxfm % t

11 create a STARTUP script 

[Root @ zw-test-db data] # cd/usr/local/mysql/
[Root @ zw-test-db mysql] # cp support-files/mysql. server/etc/init. d/mysql
Cp: overwrite '/etc/init. d/mysql '? Y

12. Three Methods for starting mysql 

Method 1: 

root@zw-test-db bin]# ./mysqld_safe --user=mysql &[1] 12455 [root@zw-test-db bin]# 160830 15:18:01 mysqld_safe Logging to '/usr/local/mysql/data/zw-test-db.err'. 160830 15:18:01 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data 

Method 2: 

[root@zw-test-db bin]# /etc/init.d/mysqld restartShutting down MySQL..160830 15:18:14 mysqld_safe mysqld from pid file /usr/local/mysql/data/zw-test-db.pid ended               [ OK ] Starting MySQL.           [ OK ] [1]+ Done     ./mysqld_safe --user=mysql 

Method 3: 

[root@zw-test-db bin]# service mysqld restart Shutting down MySQL..          [ OK ]Starting MySQL.           [ OK ] [root@zw-test-db bin]# 

13. Add Environment Variables

Echo "export PATH =\$ PATH:/usr/local/mysql/bin">/root/. bash_profile
Source/root/. bash_profile

14. Login 

[Root @ zw-test-db mysql] # mysql-u root-p Enter password: Welcome to the MySQL monitor. commands end with; or \ g. your MySQL connection id is 3 Server version: 5.7.14-log Copyright (c) 2000,201 6, 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. root @ localhost [(none)]> show databases; -- the system prompts You to change the password ERROR 1820 (HY000): You must reset your password using alter user statement before executing this statement.

15. Change Password 

root@localhost [(none)]>alter user user() identified by '123456'; Query OK, 0 rows affected (0.00 sec) mysql> flush privileges; Query OK, 0 rows affected (0.00 sec) root@localhost [(none)]>show databases;+--------------------+ | Database   | +--------------------+ | information_schema | | mysql    | | performance_schema | | sys    | +--------------------+ 4 rows in set (0.00 sec) 

You can view the database.

16. Before version 5.6, account security reinforcement is required,And later, the test database was gone.

Delete from mysql. user where user! = 'Root' or host! = 'Localhost'; -- delete non-root users. The login host is not the localhost account flush privileges; alter user () identified by '000000'; drop database test; truncate mysql. db;

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.