Install MySQL5.5.25a source code in RHELServer6.3

Source: Internet
Author: User
OS: RHELServer6.3MySQL: mysql-5.5.25a.tar.gz dependent package: ncurses-5.9.tar.gzbison-2.5.tar.gz install MySQL I. Install dependency package (1) ncurses [root @ test ~] # Cd/data1/lnmp/[root@testlnmp1_tar-xzfncurses-5.9.tar.

OS: RHEL Server 6.3

MySQL:Mysql-5.5.25a.tar.gz

Dependent packages:

Ncurses-5.9.tar.gz

Bison-2.5.tar.gz

Install MySQL

1. Install the dependency package

(1) ncurses

[Root @ test ~] # Cd/data1/lnmp/

[Root @ test lnmp] # tar-xzf ncurses-5.9.tar.gz

[Root @ test lnmp] # cd ncurses-5.9

[Root @ test ncurses-5.9] #./configure

[Root @ test ncurses-5.9] # make & make install

(2) bison

[Root @ test lnmp] # tar-xzf bison-2.5.tar.gz

[Root @ test lnmp] # cd bson-2.5

[Root @ test bison-2.5] #./configure

[Root @ test bison-2.5] # make & make install

Ii. Install the cmake tool for MySQL Compilation

[Root @ test lnmp] # tar-xzf cmake-2.8.8.tar.gz

[Root @ test lnmp] # cd cmake-2.8.8

[Root @ test cmake-2.8.8] #./configure

[Root @ test cmake-2.8.8] # make & make install

Iii. Install MySQL with source code

(1) create a user and group running MySQL

[Root @ test ~] # Groupadd mysql

[Root @ test ~] # Useradd-M-g mysql-s/sbin/nologin mysql

(2) create related directories

[Root @ test ~] # Mkdir/usr/local/mysql

[Root @ test ~] # Mkdir/var/lock/mysql

[Root @ test ~] # Mkdir/var/run/mysql

[Root @ test ~] # Mkdir/var/log/mysql

[Root @ test ~] # Mkdir/data1/mysql_db

[Root @ test ~ ] # Chown-R mysql: mysql/usr/local/mysql/

[Root @ test~]# Chown mysql: mysql/var/run/mysql/

[Root @ test~]# Chown mysql: mysql/var/lock/mysql/

[Root @ test~]# Chown mysql: mysql/Var/log/mysql/

[Root @ test~]# Chown mysql: mysql/data1/mysql_db/

 

Bytes ------------------------------------------------------------------------------------------

Note:

The reason for creating the/var/lock/mysql and/var/run/mysql directories is that the mysql server is started by the mysql user. While/Var/lock/And/Var/run/These two directories are onlyRootTherefore, mysql users cannot create mysql. lock and mysql. pid files. Therefore/Var/lock/And/Var/run/Create another directory for these two directories, for example, mysql. Change the directory owner and group to the mysql user and group. This method is also used for ease of management. For example, if logs are stored in/var/log/mysql/, logs will only rotate in this directory for ease of management; # chown mysql: mysql/var/run/mysql // var/lock/mysql // var/log/mysql/

Error:

If the database/Data1/mysql_db/The directory permission settings are incorrect. The following error may occur when mysql is started.

[Root @ test ~] # Tail/var/log/mysql. log

120713 17:15:21 mysqld_safe Starting mysqld daemon with databases from/data1/mysql_db

/Usr/local/mysql/bin/mysqld: File './mysql-bin.index' not found (Errcode: 13)

120713 17:15:21 [ERROR] Aborting


120713 17:15:21 [Note]/usr/local/mysql/bin/mysqld: Shutdown complete


120713 17:15:21 mysqld_safe mysqld from pid file/var/run/mysql. pid ended

[Root @ test ~] #
Solution:Mysql is used to start the database. Therefore, change the owner and group of the created database directory/data1/mysql_db/to mysql.
[Root @ test ~] # Chown-R mysql: mysql/data1/mysql_db/
We recommend that you perform this step when initializing the database. After initialization, you can check whether the permissions of the newly created files and directories under this directory are correct. If yes, you do not need to perform this step.
To ensure security, you can specify the user mysql to initialize the database: #./Mysql_install_db  -- User = mysql \ -- defaults-file =/etc/my. cnf \ -- basedir =/usr/local/mysql/\ -- datadir =/data1/mysql_db Bytes ----------------------------------------------------------------------------------------

(3) install MySQL with source code

[Root @ test ~] # Cd/data1/lnmp/

[Root @ test lnmp] # tar-xzf mysql-5.5.25a.tar.gz

[Root @ test lnmp] # cd mysql-5.5.25a

[Root @ test mysql-5.5.25a] # Cmake.-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \
-DSYSCONFDIR =/etc \
-DINSTALL_MANDIR =/usr/share/man \
-DMYSQL_UNIX_ADDR =/tmp/mysqld. sock \

-DMYSQL_DATADIR =/data1/mysql_db \

-DEXTRA_CHARSETS = all \

-DDEFAULT_CHARSET = utf8 \

-DWITH_READLINE = ON

-DWITH_SSL = system \

-DWITH_DEBUG= 0\

-DWITH_PARTITION_STORAGE_ENGINE = 1 \

-DWITH_INNOBASE_STORAGE_ENGINE = 1 \

-DWITH_ARCHIVE_STORAGE_ENGINE = 1 \

-DWITH_FEDERATED_STORAGE_ENGINE = 1 \

-DWITH_BLACKHOLE_STORAGE_ENGINE = 1 \

-DINSTALL_LAYOUT = STANDALONE \

-DENABLED_LOCAL_INFILE= 1\

-DENABLED_PROFILING = 1 \

-DMYSQL_MAINTAINER_MODE = 0 \

-DWITH_EMBEDDED_SERVER = 1 \

-DMYSQL_TCP_PORT = 3306 \

-DMYSQL_USER = mysql

[Root @ test mysql-5.5.25a]# Make

[Root @ test mysql-5.5.25a]# Make install

Bytes ------------------------------------------------------------------------------------------

[Root @ test mysql-5.5.25a] #Cmake. LH

Note:

The following errors may occur during compilation.

-- Cocould NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline. cmake: 83 (MESSAGE ):

Curses library not found. Please install appropriate package,


Remove CMakeCache.txt and rerun cmake. On Debian/Ubuntu, package name is libncurses5-dev, on RedHat and derivates it is ncurses-devel.

Call Stack (most recent call first ):

Cmake/readline. cmake: 127 (FIND_CURSES)

Cmake/readline. cmake: 217 (MYSQL_USE_BUNDLED_LIBEDIT)

CMakeLists.txt: 268 (MYSQL_CHECK_READLINE)

 

-- Refreshing incomplete, errors occurred!

Error cause:

This is because the curses library is not installed. Debian/UbuntuTo install the Platform Libncurses5-dev, RHEL Platform Installation Ncurses-devel .
Solution: [Root @ test mysql-5.5.25a] #Yum install ncurses-devel # or source code install [root @ test mysql-5.5.25a] # rm-rf CMakeCache.txt remove the CMakeCache.txt File [Root @ test mysql-5.5.25a] # cmake .#Compile again! Bytes ------------------------------------------------------------------------------------------

(4)CreateMySQLConfiguration File

[Root @ test mysql-5.5.25a] # cp support-files/my-huge.cnf/etc/my. cnf

[Root @ test mysql-5.5.25a] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld
[Root @ test mysql-5.5.25a] # chmod 755/etc/rc. d/init. d/mysqld
[Root @ test mysql-5.5.25a] # echo"Export PATH = $ PATH:/usr/local/mysql/bin ">/ect/profile [Root @ test mysql-5.5.25a] # source/etc/profile
Bytes ------------------------------------------------------------------------------------------

Note:

InMysql-5.5.25a/Support-filesTotal5TypeMy. cnfConfiguration file.

★My-small.cnf: for small databases, this configuration file is designed for servers with physical memory less than 64 MB.

★My-medium.cnf: Applicable to physical32 MBTo64 MBSpecifically for runningMySQLServer or physical128 MBAbove.

★My-large.cnf: Applicable to physical512 MBThe above is dedicated to runningMySQLDatabase server.

★My-huge.cnf: Applicable to physical1 GBTo2 GBSpecifically for runningMySQLDatabase server.

★My-innodb-heavy-4G.cnf: Applicable to physical server4 GBAnd complex QueryMySQLDatabase.

Bytes ------------------------------------------------------------------------------------------

(5) modify the/etc/rc. d/init. d/mysqld script file

Modify the variables in the script mysqld Based on the configuration parameters specified during cmake and the parameters in the my. cnf configuration file. The parameters in the my. cnf configuration file take precedence over the parameters specified during cmake. If no corresponding parameter is set in the my. cnf configuration file, the database runtime will take the parameter specified in cmake as the standard. The parameter priority in my. cnf is higher than the Configuration Parameter in cmake.

[Root @ test ~] # Vim/Etc/rc. d/init. d/mysqld

Basedir =/usr/local/mysql

Datadir =/data1/mysql_db

Lockdir = '/var/lock/mysql'

Lock_file_path = "$ lockdir/mysql. lock"

Mysqld_pid_file_path =/var/run/mysql. pid

(6) modify some parameters in the/etc/my. cnf configuration file according to the cmake configuration. If no corresponding parameter is set in the my. cnf configuration file, the database runtime will take the parameter specified in cmake as the standard. The parameter priority in my. cnf is higher than the Configuration Parameter in cmake.
[Root @ test ~] # Vim/Etc/my. cnf
# The following options will be passed to all MySQL clients [client] # password = your_passwordport = 3306 socket =/tmp/mysql. sock
# The MySQL server [mysqld] user = mysqlport = 3306 socket =/tmp/mysql. sockbasedir =/Usr/local/mysqlDatadir =/data1/mysql_dbpid-file =/var/run/mysql. pidlog-error =/var/log/mysql. logcharacter-set-server = utf8
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.