Compile and install MySQL 5.5.x and MySQL 5.5.x in Linux source code

Source: Internet
Author: User

Compile and install MySQL 5.5.x and MySQL 5.5.x in Linux source code

Linux: CentOS 6.5

MySQL version: 5.5.20, attached: [Click to download]

1. Install cmake

MySQL 5.5 and later versions have been replaced by the cmake tool./configure compilation and configuration method.

Therefore, we must first compile and install the cmake tool in the system source code.

Download cmake

[root@ruxingli soft]# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz

Extract

[root@ruxingli soft]# tar zxvf cmake-2.8.4.tar.gz

[root@ruxingli soft]# cd cmake-2.8.4[root@ruxingli cmake-2.8.4]# ./configure[root@ruxingli cmake-2.8.4]# make && make install

2. Ensure that the following system software packages are installed:

Run the rpm-qa | grep name command to verify whether all of the following software packages have been installed.

Gcc * gcc-c ++ * autoconf * automake * zlib * libxml * ncurses-devel * libgcrypt * libtool *

If the related software package is missing, you can install it online using yum-y install, or find it directly from the system installation disc and install it using rpm-ivh.

3. system tests before installation

Create the mysql installation directory and data storage directory

[root@ruxingli cmake-2.8.4]# mkdir -p /usr/local/mysql5.5.20

Create users and user groups

[root@ruxingli cmake-2.8.4]# groupadd mysql
[root@ruxingli cmake-2.8.4]# useradd -g mysql mysql

Grant the data storage directory permission

[root@ruxingli mysql-5.5.20]# chown mysql:mysql -R /usr/local/mysql5.5.20/

4. Compile and install MySQL5.5.20

[root@ruxingli soft]# tar zxvf mysql-5.5.20.tar.gz[root@ruxingli soft]# cd mysql-5.5.20

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql5.5.20/ -DSYSCONFDIR=/etc/ -DMYSQL_DATADIR=/usr/local/mysql5.5.20/data/ -DMYSQL_TCP_PORT=3306 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_USER=mysql -DEXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_SSL=bundled

Possible errors:


Solution:

[root@ruxingli mysql-5.5.20]# yum install bison


Solution:

Remove-DMYSQL_USER = mysql

[root@ruxingli mysql-5.5.20]# make[root@ruxingli mysql-5.5.20]# make install

Configure and initialize the database

Create my. cnf configuration file

[root@ruxingli3 mysql5.5.20]# cp support-files/my-medium.cnf /etc/my.cnf

Grant the execution permission to the scripts/mysql_install_db file before execution.

[root@ruxingli mysql-5.5.20]# chmod 755 scripts/mysql_install_db[root@ruxingli mysql-5.5.20]# scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql5.5.20/ --datadir=/usr/local/mysql5.5.20/data/

Create shell scripts for MySQL Database Management

[root@ruxingli mysql-5.5.20]# mkdir /usr/local/mysql5.5.20/init.d[root@ruxingli mysql-5.5.20]# cp support-files/mysql.server /usr/local/mysql5.5.20/init.d/mysql

Grant the shell script executable permission:

[root@ruxingli mysql-5.5.20]# chmod +x /usr/local/mysql5.5.20/init.d/mysql
Start MySQL

[root@ruxingli mysql-5.5.20]# /usr/local/mysql5.5.20/init.d/mysql start

If startup fails, see http://blog.csdn.net/zalion/article/details/9274263

My solution is:

[root@ruxingli3 mysql]# rm -rf /var/lock/subsys/mysql

Use command lines to manage MySQL servers

[root@ruxingli3 mysql5.5.20]# /usr/local/mysql5.5.20/bin/mysql
Set the initial password for the root account

[root@ruxingli3 mysql5.5.20]# /usr/local/mysql5.5.20/bin/mysqladmin -u root password '123456'
Enter the command line MySQL

[root@ruxingli3 mysql5.5.20]# /usr/local/mysql5.5.20/bin/mysql -u root -p123456

Deletes an empty password account for an anonymous connection to the local machine.

mysql> use mysql;mysql> delete from user where password='';mysql> flush privileges;mysql> select Host,User,Password from user;mysql> exit


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.