MySQL installation (source code installation mode) and mysql source code installation mode

Source: Internet
Author: User

MySQL installation (source code installation mode) and mysql source code installation mode

MySQL installation (RPM installation mode) and directory structure

MySQL installation (Binary installation mode)

MySQL installation (source code installation mode)



This article uses the mysql source code for installation, which is a little troublesome.

CentOS release 5.11 + mysql-5.6.22


To use the source code for compilation, You need to download a tool cmake:

What's Cmake? Official Instructions are as follows:

CMake is a family of tools designed tobuild, test and package software. CMake is used to control the software compilationprocess using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in thecompiler environment of your choice.

Cmake official:Http://www.cmake.org/download/


The cmake version installed in this test:

Release Candidate (3.2.0-rc2)-Source distributions-Unix/Linux Source (has \ n line feeds0000-cmake-3.2.0-rc2.tar.gz


Cmake unzip:

Ll/usr/local/src/cmake-3.2.0-rc2.tar.gz

Tar zxvfcmake-3.2.0-rc2.tar.gz

Mv/usr/local/src/cmake-3.2.0-rc2/usr/local/cmake


Compile and install:

Cd/usr/local/cmake/

./Configure


# After configure is complete, the system prompts: now run gmake, and then execute gmake.

Gmake

Make

Make install


Install mysql. For more information, see:Installing MySQL Using a Standard Source Distribution


Create a mysql user and group first:

Groupadd mysql

Useradd-r-g mysql


Current mysql instance:(Size 30 M)

Http://ftp.iij.ad.jp/pub/db/mysql/Downloads/MySQL-5.6/MySQL-5.6.22-1.linux_glibc2.5.src.rpm


Unzip the rpm package:

Music MySQL-5.6.22-1.linux_glibc2.5.src.rpm/usr/local/src

Rpm2cpioMySQL-5.6.22-1.linux_glibc2.5.src.rpm | cpio-div


Tar zxvf mysql-5.6.22.tar.gz

Mv/usr/local/src/mysql-5.6.22/usr/local/mysql


Compile mysql :(Use cmake for Version 5.5 or later, and use./configure for version 5.1 or later.)

Cd/usr/local/mysql

 

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

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

-DMYSQL_TCP_PORT = 3306 \

-DSYSCONFDIR =/etc \

-DEXTRA_CHARSETS = all \

-DDEFAULT_CHARSET = utf8 \

-DDEFAULT_COLLATION = utf8_general_ci \

-DENABLED_LOCAL_INFILE = 1 \

-DWITH_INNOBASE_STORAGE_ENGINE = 1 \

-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \

-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1

 

# For more information about the preceding Configuration parameters, see MySQL Source-Configuration Options.

Make

Make install


Set the root directory owner:

Chown-R mysql: mysql/usr/local/mysql


Copy the service and configuration file to the system configuration file:

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

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


Edit the mysql configuration file and add the following parameters: vi/etc/my. cnf

[Mysqld]

Basedir =/usr/local/mysql

Datadir =/usr/local/mysql/data

Port = 3306

Server_id = 1


Initialize the database:

Chmod 755/usr/local/mysql/scripts/mysql_install_db

/Usr/local/mysql/scripts/mysql_install_db -- user = mysql -- basedir =/usr/local/mysql -- datadir =/usr/local/mysql/data


Set to start mysqld at startup:

Chkconfig mysqld on


Set environment variables: vi/root/. bash_profile

# PATH = $ PATH: $ HOME/bin

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


[Root @ localhost ~] # Source/root/. bash_profile


Start the mysqld service:

Chmod 755/etc/init. d/mysqld

/Etc/init. d/mysqld start

Service mysqld restart



Set the mysql password and related settings:

/Usr/local/mysql/bin/mysql_secure_installation

 

Done !! Successfully logged on!




The installation is complete. first fill in the water.


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.