Mysql compilation and installation tutorial in Linux (centos), centosmysql

Source: Internet
Author: User

Mysql compilation and installation tutorial in Linux (centos), centosmysql

How to compile and install mysql in Linux

# Viewing the linux release version

Cat/etc/issue

# View the Linux kernel version

Uname-r

Test Environment centOS6.6

 

I. Preparations before MySQL compilation and installation in Linux

Install the tools and libraries required for compiling source code online (if you cannot connect to the Internet, prepare software or system disk in advance)

Yum install gcc-c ++ ncurses-devel perl

From mysql5.5 to source code compilation, you need to use the cmake compilation tool. Download the cmake source code from the http://www.cmake.org and compile the installation.

Wget http://www.cmake.org/files/v3.3/cmake-3.3.0.tar.gz

Tar-xzvf cmake-3.3.0.tar.gz

Cd cmake-3.3.0

./Bootstrap; make install

Cd ~

2. Set MySQL users and groups

New mysql user group and mysql user group

Groupadd mysql

Useradd-r-g mysql

3. Create a directory required by MySQL

Mkdir-p/usr/local/mysql

Mkdir-p/data/mysqldb

4. Download and decompress the MySQL source package

You can select an image from http://dev.mysql.com/downloads/mirrors.htmlto download the source code file or download it directly.

Wget ftp://mirror.csclub.uwaterloo.ca/mysql/Downloads/MySQL-5.6/mysql-5.6.25.tar.gz

(You can set the download source by yourself)

Tar-zxv-f mysql-5.6.25.tar.gz

Cd mysql-5.6.25

V. Compile and install MySQL

From mysql 5.5, mysql source code installation began to use cmake, and the source code compilation configuration script was set.

Enter the decompressed mysql directory for execution

Cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql-DMYSQL_UNIX_ADDR =/usr/local/mysql. sock-DDEFAULT_CHARSET = utf8-DDEFAULT_COLLATION = utf8_general_ci-rows = 1-rows = 1-rows = 1-DMYSQL_DATADIR =/data/mysqldb-rows = 3306-DENABLE_DOWNLOADS = 1

Note: To re-configure the configuration, delete the CMakeCache.txt file (rm CMakeCache.txt)

Run the command

Make

Make instal

Compilation parameters:

-DCMAKE_INSTALL_PREFIX = dir_name: sets the mysql installation directory.

-DMYSQL_UNIX_ADDR = file_name: sets the listening socket path, which must be an absolute path name. The default value is/tmp/mysql. sock.

-DDEFAULT_CHARSET = charset_name: Set the character set of the server. By default, MySQL uses the latin1 (CP1252 Western Europe) Character Set. The cmake/character_sets.cmake file contains a list of allowed character set names.

-DDEFAULT_COLLATION = collation_name: Set the server's sorting rules.

The following are storage engine options:

-DWITH_INNOBASE_STORAGE_ENGINE = 1

-DWITH_ARCHIVE_STORAGE_ENGINE = 1

-DWITH_BLACKHOLE_STORAGE_ENGINE = 1

-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1

MyISAM, MERGE, MEMORY, and CSV engines are compiled to the server by default and do not need to be explicitly installed. Statically compile a storage engine to the server and use-DWITH_engine_STORAGE_ENGINE = 1

Available storage engine values include ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema)

-DMYSQL_DATADIR = dir_name: sets the mysql database file directory.

-DMYSQL_TCP_PORT = port_num: Set the mysql server listening port. The default value is 3306.

-DENABLE_DOWNLOADS = bool: whether to download optional files. For example, if this option is enabled (set to 1), cmake downloads the test suite used by Google to run unit tests.

6. Modify the directory owner and group of mysql

Modify the mysql installation directory

Cd/usr/local/mysql

Chown-R mysql: mysql.

Modify the mysql database file directory

Cd/data/mysqldb

Chown-R mysql: mysql.

VII. initialize the mysql database

Cd/usr/local/mysql

Scripts/mysql_install_db -- user = mysql -- datadir =/data/mysqldb

8. Copy the mysql service startup configuration file

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

IX. Copy the mysql Service Startup Script and add the PATH

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

Vim/etc/profile

PATH =/usr/local/mysql/bin:/usr/local/mysql/lib: $ PATH

Export PATH

Source/etc/profile

10. Start the mysql service and add it to auto-start (this step is optional and you can start it yourself later)

Service mysql start

Chkconfig -- level 35 mysql on

Check whether mysql is started.

Netstat-tulnp | grep 3306

Mysql-u root-p

The First Login Password is blank. If you can log on to the land, the installation is successful.

Set the User root Password

Mysqladmin-u root password '123'

Log on again

Mysql-uroot-p123456

References:

Http://blog.csdn.net/wendi_0506/article/details/39478369

Http://blog.csdn.net/hellozpc/article/details/47030415

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.