CentOS6.9 + Mysql5.7.18 source code installation tutorial

Source: Internet
Author: User

CentOS6.9 + Mysql5.7.18 source code installation tutorial

CentOS6.9 + Mysql5.7.18 source code installation, the following operations are performed under the root user.

1. Install dependency tools

Cmake make3.75 + gcc4.4.6 + Boost1.59.0 bison ncurses

Yum install-y cmake, make, gcc, gcc-c ++, bison, ncurses, ncurses-devel

Cd/opt

Wgethttps: // sourceforge.net/projects/boost/files/boost/1.59#/boost_000059_0.tar.gz

Or want

Tar-zxvf boost_000059_0.tar.gz-C/usr/local/

2. Download mysql for Installation

Git clone https://github.com/mysql/mysql-server.git

Install yum install git without git

Select 5.7

Create a mysql user. The user group is root.

Useradd-r-g root-s/bin/false mysql

3. Execute cmake

Cd/opt/mysql-server5.7

Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \

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

-DWITH_BOOST =/usr/local/boost_1_59_0 \

-DMYSQL_UNIX_ADDR =/tmp/mysql. sock \

-DSYSCONFDIR =/etc \

-DEFAULT_CHARSET = utf8 \

-DDEFAULT_COLLATION = utf8_general_ci \

-DENABLED_LOCAL_INFILE = 1 \

-DEXTRA_CHARSETS = all

-DCMAKE_INSTALL_PREFIX: installation path-DMYSQL_DATADIR: data storage directory-DWITH_BOOST: boost source code path-DSYSCONFDIR: my. cnf configuration file directory-DEFAULT_CHARSET: Database default character encoding-DDEFAULT_COLLATION: Default sorting rule-DENABLED_LOCAL_INFILE: Allow data import from this file-DEXTRA_CHARSETS: Install all character sets 4. Compile and install

Make-j 'grep processor/proc/cpuinfo | wc-l'

Make install

-The-j parameter specifies the number of threads for compilation based on the number of CPU cores, which can speed up compilation.

If compilation fails, you need to delete the cache file of the pre-compilation configuration parameters generated by cmake and the files generated after the make compilation, and then re-compile the files.

Cd/opt/mysql-server5.7

Rm-f CMakeCache.txt

Make clean

5. initialize the system database

Vim/etc/my. cnf

Enter the insert mode and replace the original content with the following:CentOS6.9 + Mysql5.7.18 source code installation tutorial

[Client]

Port = 3306

Socket =/temp/mysql. sock

[Mysqld]

Character-set-server = utf8

Collation-server = utf8_general_ci

Skip-external-locking

Skip-name-resolve

User = mysql

Port = 3306

Basedir =/usr/local/mysql

Datadir =/usr/local/mysql/data

Tmpdir =/usr/local/mysql/temp

# Server_id = .....

Socket =/usr/local/mysql. sock

Log-error =/usr/local/mysql/logs/mysql_error.log

Pid-file =/usr/local/mysql. pid

Open_files_limit = 10240

Back_log = 600

Max_connections = 500

Max_connect_errorrs = 6000

Wait_timeout = 605800

# Open_tables = 600

# Table_cache = 650

# Opened_tables = 630

Max_allowed_packet = 32 M

Sort_buffer_size = 4 M

Join_buffer_size = 4 M

Thread _ cache_size = 300

Query_cache_type = 1

Query_cache_size = 256 M

Query_cache_limit = 2 M

Query_cache_min_res_unit = 16 k

Tmp_table_size = 256 M

Max_heap_table_size = 256 M

Key_buffer_size = 256 M

Read_buffer_size = 1 M

Read_rnd_buffer_size = 16 M

Bulk_insert_buffer_size = 64 M

Lower_case_table_names = 1

Default-storage-engine = INNODB

Innodb_buffer_pool_size = 2G

Innodb_log_buffer_size = 32 M

Innodb_log_file_size = 128 M

Innodb_flush_method = O_DIRECT

#####################

Thread_concurrency = 32

Long_query_time = 2

Slow-query-log = on

Slow-query-log-file =/usr/local/mysql/logs/mysql-slow.log

[Mysqldump]

Quick

Max_allowed_packet = 32 M

[Mysqld_safe]

Log-error =/var/log/mysqld. log

Pid-file =/var/run/mysqld. pid

Cd/usr/local/mysql

Mkdir data

Mkdir logs

Mkdir temp

Chmod 0770-R.

./Mysqld -- initialize -- user = mysql -- datadir =/usr/local/mysql/data -- basedir =/usr/local/mysql -- socket =/tmp/mysql. sock

Before MySQL 5.7.6, it was bin/mysql_install_db -- user.

After the command is executed, check the logs/mysql_error.log file and write down the temporary root password.

A temporary password is generated for root @ localhost: xxxxxxxxxx

6. Configure mysql

Chkconfig -- add mysqld # add to System Service

Chkconfig mysqld on # Start upon startup

Service mysqld start cannot be started successfully. It is started in safe mode.

Chown-R mysql: root/var/run/mysqld

./Bin/mysqld_safe -- defaults-file =/etc/my. cnf -- user = mysql &

./Mysql-uroot-p

Enter the temporary password in mysql_error.log to log on to the mysql console.

Set password = 'asdfghjkl '';

Query OK, 0 rows affected (0.00 sec)

Show warnings;

Stop mysql

Mysqladmin-u root-p shutdown

Enter the password you just set to stop successfully.

Next, you can use the system service to start mysql:

Service mysqld start # start the mysql service

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.