Build and install MySQL5.7.16 under CentOS

Source: Internet
Author: User
Tags mkdir

First, Introduction

MySQL is a relational database management system developed by the Swedish MySQL AB company and is currently part of Oracle's product portfolio. MySQL's most popular relational database management system, MySQL is one of the best RDBMS (relational database Management system, relational databases management systems) application software in WEB applications.

MySQL is an associated database management system that keeps data in separate tables rather than putting all of the data in a large warehouse, which increases speed and increases flexibility.

The SQL language used by MySQL is the most commonly used standardized language for accessing databases. MySQL software uses a dual licensing policy, which is divided into community and commercial version, due to its small size, fast, low total cost of ownership, especially the open source, the development of the general small and medium-sized web site to choose MySQL as the site database.

Thanks to the performance of its community edition, PHP and Apache make a good development environment.

Second, prepare

1. Turn off SELinux:

Sed-i ' s/selinux=enforcing/selinux=disabled/'/etc/selinux/config

2. Installation related tools

Yum-y Install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool Bison

3. Software download

Download MySQL:

wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.16.tar.gz

Download boost:

wget Http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar

4, clean up the environment (starting from MySQL 5.7.5 boost Library is required)

Check the Boost version:

Rpm-qa boost*

Uninstall boost-* and other libraries:

Yum-y Remove boost-*

5, uninstall the system has installed MySQL

View the installed MySQL

Rpm-qa|grep-i MySQL

Uninstall the installed MySQL

Yum Remove MySQL

View the remaining installation packages

Rpm-qa|grep-i MySQL

Remove the installation package individually

Rpm-qa|grep-i MySQL

Rm-rf/etc/my.cnf

Rm-rf/usr/share/mysql or Rm-rf/var/lib/mysql according to their own environment to delete

6. Create MySQL user, group and directory

Groupadd MySQL

Mkdir/usr/local/mysql

Mkdir-p/usr/local/mysql/data

Useradd-g mysql-d/usr/local/mysql-s/sbin/nologin MySQL

Second, installation

1. Install boost

Starting the boost library from MySQL 5.7.5 is required, download the Boost library, copy it to the/usr/local/boost directory after decompression (then re-cmake and add the options in the following options-dwith_boost=/usr/local/ Boost

TAR-ZXVF boost_1_59_0.tar.gz-c/usr/local/boost

2, compile and install MySQL (new version of MySQL with CMake compiled installation)

TAR-ZXVF mysql-5.7.16.tar.gz

CD mysql-5.7.16

Cmake-dcmake_install_prefix=/usr/local/mysql \

-dmysql_datadir=/usr/local/mysql/data \

-ddefault_charset=utf8 \

-DDEFAULT_COLLATION=UTF8_GENERAL_CI \

-dmysql_tcp_port=3306 \

-dmysql_user=mysql \

-dwith_myisam_storage_engine=1 \

-dwith_innobase_storage_engine=1 \

-dwith_archive_storage_engine=1 \

-dwith_blackhole_storage_engine=1 \

-dwith_memory_storage_engine=1 \

-ddownload_boost=1-dwith_boost=/usr/local/boost

Common parameters:

Cmake_install_prefix: Specifies the installation directory of the MySQL program, default/usr/local/mysql

Default_charset: Specifies the server default character set, default Latin1

Default_collation: Specifies the default proofing rules for the server, default Latin1_general_ci

Enabled_local_infile: Specifies whether to allow load DATA INFILE to be executed locally, by default off

With_comment: Specifying compilation Notes Information

With_xxx_storage_engine: Specifies a storage engine that is statically compiled to MySQL, and the Myisam,merge,member and CSV four engines are compiled to the server by default and do not require special designation.

Without_xxx_storage_engine: Specifying a storage engine that does not compile

Sysconfdir: Initialize parameter file directory

Mysql_datadir: Data Files directory

Mysql_tcp_port: Service port number, default 3306

Mysql_unix_addr:socket file path, default/tmp/mysql.sock

3. Compile and install

Make && make install

4. Set permissions and initialize MySQL system authorization form

Set permissions:

Chown-r Mysql:mysql/usr/local/mysql

Chown-r Mysql:mysql/usr/local/mysql/data

Initialization

/usr/local/mysql/bin/mysqld--initialize-insecure--user=mysql--basedir=/usr/local/mysql--datadir=/usr/local/ Mysql/data


5. Create a configuration file

MY.CNF backup that will be generated by default

Mv/etc/my.cnf/etc/my.cnf.bak

Copy profile template to new MySQL configuration file

Cp/usr/local/mysql/support-files/my-default.cnf/etc/my.cnf

You can modify the new profile options as needed, without modifying the configuration options, and MySQL runs on the default configuration parameters.

as follows, I modify the configuration file/etc/my.cnf, which is used to set the encoding to UTF8 to prevent garbled

[Mysqld]

Character_set_server=utf8

init_connect= ' SET NAMES UTF8 '

[Client]

Default-character-set=utf8

6. Configure the MySQL service to boot automatically

Cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld

chmod 755/etc/init.d/mysqld

Check the list of self-initiated items without mysqld this, and if not, add Mysqld:

Chkconfig–list mysqld

Chkconfig–add mysqld

Set MySQL to automatically start at 345 level

Chkconfig–level 345 mysqld on

or set boot start with this command: Chkconfig mysqld on #加入开机启动

Vi/etc/init.d/mysqld #编辑

Basedir =/usr/local/mysql #MySQL程序安装路径

DataDir =/usr/local/mysql/data #MySQl数据库存放目录

Service mysqld Start #启动

Vi/etc/profile #把mysql服务加入系统环境变量: Add the following line at the end

Export path= $PATH:/usr/local/mysql/bin

: wq! #保存退出

7. The following two lines link the MYSLQ library file to the default location of the system, so you can compile software like PHP without specifying the MySQL library file address.

Ln-s/usr/local/mysql/lib/mysql/usr/lib/mysql This file is not currently

Ln-s/usr/local/mysql/include/mysql/usr/include/mysql

8, Shutdown-r now #需要重启系统, wait for the system to restart after the operation continues under the terminal command line

Mysql_secure_installation #设置Mysql密码

Press Y to enter as prompted, and then type 2 password , continue to press Y to enter, until Setup is complete

or modify the password directly/usr/local/mysql/bin/mysqladmin-u root-p password "123456" #修改密码

Service mysqld Restart #重启

To this, MySQL installation is complete!

9. Start/restart/stop of MySQL service

Start MySQL services: Service mysqld start

Restart MySQL Services: Service mysqld restart

Stop MySQL Services: Service mysqld stop

Accessing the MySQL Database

Connect MySQL, enter the random password generated by the initialization

Mysql-uroot-p

Change root new password such as 123456

mysql> alter user ' root ' @ ' localhost ' identified by ' 123456 ';

Mysql> quit;

Mysql> exit; (with the best effect, it is the MySQL connection)

Reconnect MySQL with the new password

Mysql-uroot-p

14. Set remote access to the database

Log in to MySQL database execution using mysql-h localhost-u root-p

Grant all privileges on. to [e-mail protected] '% ' identified by ' password ' enables remote users to access the database and execute commands: Flush privileges;


Build and install MySQL5.7.16 under CentOS

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.