Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Source code compilation and installation of MySQL 5.7.5 under CentOS 6.7

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Description: CentOS 6.7 source code compilation and installation of MySQL 5.7.5

1. Install related tools

# yum-y install gcc-c++ ncurses-devel cmake make perl gcc autoconf automake zlib libxml libgcrypt libtool bison

two。 Clean up the environment

Check the boost version:

# rpm-qa boost*

Uninstall libraries such as boost-*:

# yum-y remove boost-*

3. Download the mysql source package

Download mysql5.7 source code:

Http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.5-m15.tar.gz

Mysql Mirror Station:

Http://mirrors.sohu.com/mysql/

4. Create mysql users, groups, and directories

# groupadd mysql

# mkdir / home/mysql

# mkdir / home/mysql/data

# useradd-g mysql-d / home/mysql

5. Matters needing attention

The Boost library is required from MySQL 5.7.5. Download the Boost library, unzip it and copy it to the / usr/local/boost directory, then re-cmake and add the option-DWITH_BOOST=/usr/local/boost to the later options.

(download: http://sourceforge.net/projects/boost/files/boost/)

Demand boost1.57.0

Wget-c http://liquidtelecom.dl.sourceforge.net/project/boost/boost/1.57.0/boost_1_57_0.tar.gz

6. The new version of mysq is compiled and installed with cmake

Decompress the mysql source code package mysql-5.7.5-m15.tar.gz

# tar-xzvf mysql-5.7.5-m15.tar.gz

The following actions are performed in the root directory of the decompressed source package

Cmake compilation

# cmake-DCMAKE_INSTALL_PREFIX=/home/mysql-DMYSQL_DATADIR=/home/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: specify 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 proofreading rules for the server, and the default latin1_general_ci

ENABLED_LOCAL_INFILE: specifies whether to allow local execution of LOAD DATA INFILE, default OFF

WITH_COMMENT: specify compilation remarks information

WITH_xxx_STORAGE_ENGINE: specifies the storage engine statically compiled to mysql. MyISAM,MERGE,MEMBER and CSV engines are compiled to the server by default and do not need to be specified.

WITHOUT_xxx_STORAGE_ENGINE: specifies a storage engine that is not compiled

SYSCONFDIR: initialization parameter file directory

MYSQL_DATADIR: data file directory

MYSQL_TCP_PORT: service port number. Default is 3306.

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

Compilation and installation

# make & & make install

Rerun the configuration after an error, and delete the CMakeCache.txt file

# make clean

# rm-f CMakeCache.txt

7. Set permissions and initialize the MySQL system authorization table

Set permissions

# cd / home/mysql

# chown-R mysql.

# chgrp-R mysql.

When initializing the operation with root, add the-user=mysql parameter to generate a random password (be careful to save the login)

# cd / home/mysql

# bin/mysqld-initialize-user=mysql-basedir=/home/mysql-datadir=/home/mysql/data

8. Create a profile

My.cnf backups generated by default

# mv / etc/my.cnf / etc/my.cnf.bak

Enter the mysql installation directory to support the file directory

# cd / home/mysql/support-files

Copy the profile template to the new mysql profile

# cp my-default.cnf / etc/my.cnf

You can modify the new configuration file options as needed, without modifying the configuration options, and mysql runs according to the default configuration parameters.

The following is my modification of the configuration file / etc/my.cnf, which is used to set the encoding to utf8 to prevent garbled code.

[mysqld]

Character_set_server=utf8

Init_connect='SET NAMES utf8'

[client]

Default-character-set=utf8

9. Configure mysql service boot to start automatically

Copy the startup file to / etc/init.d/ and repeat the command as mysqld

# cp / home/mysql/support-files/mysql.server / etc/init.d/mysql

Increase the executive authority

# chmod 755 / etc/init.d/mysqld

Check that there is no mysqld in the list of self-launch items, and if not, add mysqld:

# chkconfig-list mysqld

# chkconfig-add mysqld

Set MySQL to start automatically at level 345

# chkconfig-- level 345 mysqld on

Or use this command to set boot:

# chkconfig mysqld on

10. Start / restart / stop the mysql service

Start the mysql service

# service mysqld start

Restart the mysql service

# service mysqld restart

Stop the mysql service

# service mysqld stop

11. Access to mysql database

Connect to mysql and enter the random password generated by initialization

# mysql-uroot-p

Change the new root password such as 123456

Mysql > alter user 'root'@'localhost' identified by' 123456'

Mysql > quit

Mysql > exit; (equivalent to above, all exit mysql connection)

Reconnect to mysql with a new password

# mysql-uroot-p

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report