Install MySQL 5.7.6 + detailed tutorial in CentOS 7 source code, centos5.7.6

Source: Internet
Author: User

Install MySQL 5.7.6 + detailed tutorial in CentOS 7 source code, centos5.7.6

Configuration instructions

Linux: Centos7

MySQL version: MySQL5.7.16

This document applies to MySQL version> = 5.7.6

1. Uninstall the mariadb package carried by CentOS7 by default

# Check the mariadb installation package [root @ wing ~] # Rpm-qa | grep-I mysql [root @ wing ~] # Rpm-qa | grep-I mariadbmariadb-libs-5.5.50-1.el7_2.x86_64 # uninstall the mariadb installation package [root @ wing ~] # Rpm-e mariadb-libs-5.5.50-1.el7_2.x86_64error: Failed dependencies: libmysqlclient. so.18 () (64bit) is needed by (installed) postfix-2: 2.10.1-6. el7.x86 _ 64 libmysqlclient. so.18 (libmysqlclient_18) (64bit) is needed by (installed) postfix-2: 2.10.1-6. el7.x86 _ 64 [root @ wing ~] # Rpm-e mariadb-libs-5.5.50-1.el7_2.x86_64 postfix-2: 2.10.1-6. el7.x86 _ 64

2. Obtain all MySQL versions (5.0.15-latest ).

Http://downloads.mysql.com/archives/community/

3. Install the compilation software

yum install -y cmake make gcc gcc-c++

4. Create a MySQL installation directory

# For example, the installation directory of MySQL is/usr/local/mysqlmkdir-p/usr/local/mysql.

5. decompress the MySQL source package

tar -zxvf mysql-5.7.16.tar.gz

6. Create mysql users and user groups

# Create a user group groupadd mysql # create a mysql user in the group mysqluseradd-s/bin/bash-m-g mysql

7. Install MySQL-related dependency packages

yum install -y ncurses-devel openssl-devel bison-devel libaio libaio-devel

8. boost library Installation

# This step can be omitted, add the parameter-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/usr/local/boost in the cmake stage. # Install the wget http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gztar-zxvf boost_1_59_0.tar.gz-C/usr/localmv/usr/local/boost_1_59 _ /usr/local/boostcd/usr/local/boost. /bootstrap. sh. /b2 stage threading = multi link = shared. /b2 install threading = multi link = shared

9. Create MySQL-related directories

| Directory | meaning | configuration parameters |

|: --- | ------------- | -------------- |

| Bin_log | binary log directory | log_bin_basename

Log_bin_index |

| Mydata | data file directory | datadir |

| Innodb_log | directory of InnoDB redo logs | innodb_log_group_home_dir |

| Innodb_ts | InnoDB shared tablespace directory | innodb_data_home_dir |

| Log file directory (error log + general log + slow log) | log_error

General_log_file

Slow_query_log_file |

| Relay_log | InnoDB relay log directory | relay_log_basename

Relay_log_index |

| Tmpdir | temporary file directory | tmpdir |

| Undo_log | InnoDB rollback log directory | innodb_undo_directory |

mkdir -p /data/mysql/mysql3306/bin_logmkdir -p /data/mysql/mysql3306/db_filemkdir -p /data/mysql/mysql3306/innodb_logmkdir -p /data/mysql/mysql3306/innodb_tsmkdir -p /data/mysql/mysql3306/logmkdir -p /data/mysql/mysql3306/relay_logmkdir -p /data/mysql/mysql3306/tmpdirmkdir -p /data/mysql/mysql3306/undo_log

10. Modify the user and group of the directory created in Step 9 as mysql: mysql

chown -R mysql:mysql /data/mysql/mysql3306

Place the MySQL configuration file my. cnf in The/etc directory

By default, MySQL searches for the following paths in sequence to obtain the MySQL configuration file:

/Etc/my. cnf

/Etc/mysql/my. cnf

/Etc/my. cnf/my. cnf

/Usr/local/mysql/my. cnf

~ /. My. cnf

You can use-defaults-file = xxx to specify the configuration file.

# Modify the user and group of the MySQL configuration file chown-R mysql: mysql my. cnf

Compile and install MySQL5.7.6 +

# Switch to cd/path/mysql-5.7.16 under the mysql-5.7.16 source code directory # cmakecmake-DCMAKE_BUILD_TYPE = RelWithDebInfo-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-connector =/data/mysql/mysql3306/mydata-DSYSCONFDIR /etc/my. cnf-records = 1-records = 1-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = bytes-DENABLE_DEBUG_SYNC = 0-records = 1-DENABLED_PROFILING = 1-records = 3306-records =/data/mysql /mysql3306/tmpdir/my-3306.sock-DWITH_DEBUG = 0-DWITH_SSL = yes-DWITH_SAFEMALLOC = OFF-DDOWNLOAD_BOOST = 1-DWITH_BOOST =/usr/local/boost # make # Add -The j parameter specifies multithreading, for example, make-j2 & make install-j2 uses two CPU cores for make # after this step is completed, you can go to the directory specified by the CMAKE_INSTALL_PREFIX parameter, in the MySQL installation directory, you can view the mysql-related directory and file make & make install # modify the user and User Group of the MySQL installation directory to mysql: mysqlchown-R mysql: mysql/usr/local/mysql

Initialize MySQL

'''Shell # Go To The MySQL installation directory cd/usr/local/mysql # initialize MySQL. Remember -- defaults-file =/etc/my. cnf should be placed first in the parameter. The initialization information can be viewed in the errorlog of MySQL, and a root random password will be generated in the errorlog. This random password is only owned by the root @ localhost user. Mysqld -- defaults-file =/etc/my. cnf -- initialize -- basedir =/usr/local/mysql -- datadir =/data/mysql/mysql3306/mydata -- user = mysql

1. Add MySQL Environment Variables

Vim/etc/profile # In ~ /. Add the following statement to the bashrc file: export MYSQL_HOME =/usr/local/mysql export PATH =$ {MYSQL_HOME}/bin: $ PATH #. Save the statement to make the environment variable take effect. source/etc/profile

2. Start MySQL

Mysqld_safe -- defaults-file =/etc/my. cnf & # You can view related processes through ps-ef | grep mysql.

3. log on to MySQL

Mysql-uroot-S/data/mysql/mysql3306/tmpdir/mysql. sock-p # enter the random password generated in errorlog to log on to MySQL # modify the root password to log on to mysql. Otherwise, the following situations may occur: root @ localhost: (none) 11:16:52> show databases; ERROR 1820 (HY000): You must reset your password using alter user statement before executing this statement. ERROR 1820 (HY000): You must reset your password using alter user statement before executing this statement. ERROR 1820 (HY000): You must reset your password using alter user statement before executing this statement. # modify the root password set password = 'mysql'; # in the current version, you can use a direct string to replace the previous password ('xxx') encryption method. The current version prompts: root @ localhost: (none) 11:16:54> set password = password ('mysql'); Query OK, 0 rows affected, 1 warning (0.00 sec) Warning (Code 1287 ): 'set PASSWORD = PASSWORD ('<plaintext_password>') 'is deprecated and will be removed in a future release. please use set password = '<plaintext_password>' insteadroot @ localhost: (none) 11:19:27> set password = 'mysql ';

4. Disable MySQL

Mysqladmin shutdown-uroot-S/data/mysql/mysql3306/tmpdir/mysql. sock-p # use the new password

The initialized MySQL5.7.6 + differs from MySQL5.6.xx

Different initialization tools

MySQL5.6.xx uses mysql_install_db. MySQL5.7.6 + is officially recommended for mysqld-initialize.

Different database initialization Methods

Mysql, information_schema, performance_schema, and test databases exist after MySQL5.6.xx initialization. mysql, information_schema, cece_schema, and sys databases exist after MySQL5.7.6 + initialization.

Different initialization users

After MySQL5.6.xx initialization, there are five users: root @ localhost, root @ ': 1', root @ 'hostname', ''@ 'localhost','' @ 'hostname, mysql exists after MySQL5.7.6 + initialization. sys, root @ localhost user

Initialize the root password

After MySQL5.6.xx is initialized, the root user password is blank. After MySQL5.7.6 + is initialized, a random password is generated for the root @ localhost user.
'''

Summary

The above is all about this article. I hope this article will help you in your study or work. If you have any questions, please leave a message.

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.