CentOS Compile and install MySQL (take mysql-5.6.26 as an example)

Source: Internet
Author: User
Tags centos

1) Preparation before installation

① download MySQL, get the source package from the official website, Http://dev.mysql.com/downloads/mysql
#wget http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.27.tar.gz
#tar XVF mysql-5.6.27.tar.gz
#cd mysql-5.6.27

② Check if MySQL exists
#rpm-qa | grep MySQL
If it exists, delete it.

RPM-E MySQL//normal Delete mode
RPM-E--nodeps MySQL//Only delete MySQL does not remove dependencies

③ Installation Compilation Environment

#yum-y install make gcc-c++ cmake bison-devel ncurses-devel

2) compile and install MySQL

#cmake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_datadir=/usr/local/mysql/data \
-DSYSCONFDIR=/ETC \
-dwith_myisam_storage_engine=1 \
-dwith_innobase_storage_engine=1 \
-dwith_memory_storage_engine=1 \
-dwith_readline=1 \
-dmysql_unix_addr=/var/lib/mysql/mysql.sock \
-dmysql_tcp_port=3306 \
-denabled_local_infile=1 \
-dwith_partition_storage_engine=1 \
-dextra_charsets=all \
-ddefault_charset=utf8 \
-ddefault_collation=utf8_general_ci
After the above configuration succeeds, start compiling the installation, the process will wait a while
#make && make Install

If there is no error in this process, install complete!
3) Configure MySQL

① Configure MySQL users (MySQL) and user groups (MySQL) and their permissions
#grep mysql/etc/passwd
#grep mysql/etc/group
If they are not created, do not exist, create
# Groupadd MySQL
#useradd-g MySQL MySQL
sets/usr/local/mysql users and user groups to MySQL
#chown-R mysql.mysql/usr/local/ MySQL
② initialization database
#cd/usr/local/mysql
#scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/ Local/mysql/data--user=mysql--pid-file=/usr/local/mysql/data/mysql.pid--tmpdir=/tmp/mysql
③ boot MySQL and set to boot from
#cp support-files/mysql.server/etc/init.d/mysql
#chkconfig mysql on
#service mysql start
④ configuration environment variable
Edit /etc/source file, add the above code to the end
Path=/usr/local/mysql/bin: $PATH
Export PATH
Make environment variable effective
#source/etc/profile
⑤ turn on remote access
#mysql
>grant all privileges on *.* to ' root ' @ '% ' identified by ' mypwd123 ' with GRANT OPTION;

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.