CentOS Compilation Install MySQL

Source: Internet
Author: User

1. Pre-preparation

1.1 Environment Description:
Operating system: CentOS release 6.4 (Final) [view command Cat/etc/redhat-release]
mysql:mysql-5.6.26

1.2 Completely delete the system comes with MySQL

Yum remove MySQL mysql-server mysql-libs compat-mysql*
Rm-rf/var/lib/mysql
#查看是否还有mysql安装程序
Rpm-qa|grep MySQL
RPM-E--nodeps < package name > do not check dependencies, delete rpm package directly

1.3 Installation Package Preparation

Download the compilation tool and the MySQL installation package.

CD cd/usr/local/src/
wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.26.tar.gz
wget http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz

1.4 Initial System Compilation tool

Yum install gcc gcc-c++ ncurses-devel perl-y

2, CMake installation

CD cd/usr/local/src/
TAR-XZVF cmake-2.8.10.2.tar.gz
CD cmake-2.8.10.2
./bootstrap; make; Make install

3. mysql Installation

3.1 Creating MySQL Users and Groups
Groupadd MySQL
Useradd-r-G MySQL MySQL

3.2 Creating MySQL requires a directory

Mkdir-p/usr/local/mysql
Mkdir-p/data/mysqldb

3.3 Unzip & Compile
Tar-zxv-f mysql-5.6.16.tar.gz
CD mysql-5.6.16

CMake./-dcmake_install_prefix=/usr/local/mysql-dinstall_datadir=/data/mysqldb-ddefault_charset=utf8-ddefault_ Collation=utf8_general_ci-dmysql_unix_addr=/usr/local/mysql/mysql.sock

Make&&make Install

3.4 Modifying MySQL directory Owners and Groups

Cd/usr/local/mysql
Chown-r Mysql:mysql.

Cd/data/mysqldb
Chown-r Mysql:mysql.

3.5 initial MySQL

Cd/usr/local/mysql
scripts/mysql_install_db--user=mysql--datadir=/data/mysqldb

3.6 Copy the MySQL service startup configuration file

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

Modify/ETC/MY.CNF

[Mysqld]
Basedir =/usr/local/mysql
DataDir =/data/mysqldb/

3.7 Copy the MySQL service startup script and configure the path path

CP Support-files/mysql.server/etc/init.d/mysqld

Vim/etc/profile
# End of File add
Path=/usr/local/mysql/bin:/usr/local/mysql/lib: $PATH
Export PATH

Source/etc/profile
3.8 Start the MySQL service and join the boot-up
Service mysqld Start
Chkconfig--level mysqld on

3.9 Check if the MySQL service is started

NETSTAT-TULNP | grep 3306
Mysql-u root-p

3.10 Adding a Firewall

# root User Login using/sbin/iptables
/sbin/iptables-i input-p TCP--dport 3306-j ACCEPT
/etc/rc.d/init.d/iptables Save
/etc/rc.d/init.d/iptables restart

4. mysql Installation verification

4.1 Modifying the MySQL root user password

# Change Root password
# mysql-h127.0.0.1-uroot-p
# Update Mysql.user Set Password=password ("Mysqldba") where user= ' root ';
# flush Privileges;

# mysql-u Root-ppassword//Enter the MySQL console
# mysql>use MySQL;
--This command can be skipped when executing an error
# mysql>update User Set host = '% ' where user = ' root ';
# Mysql>flush privileges;
# Mysql>select host, user from user; Check that '% ' is inserted into the database
# Mysql>quit

5. Frequently Asked Questions:


5.1 MySQL Problem resolution:-bash:mysql:command not Found
Because the path to the MySQL command is under/usr/local/mysql/bin, so when you use the MySQL command directly,
The system checks this command under/usr/bin, so I can't find it.
The solution is:
Ln-s/usr/local/mysql/bin/mysql/usr/bin make a link


Reference files:

Linux CentOS6.5 compile and install MySQL 5.6.16 "Give a detailed tutorial"
http://blog.csdn.net/wendi_0506/article/details/39478369

CentOS Compilation Install MySQL

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.