Before compiling and installing MySQL, let's look at what MySQL is doing.
1, MySQL is an open-source small relational database management system, open for the Swedish MySQL AB company, currently MySQL is widely used in small and medium-sized web sites on the Internet. Because of its small size, fast speed, low total cost of ownership, especially the open source, many kinds of small sites to reduce the overall cost of the site to choose MySQL as the site database.
2. Install Mysql
2.1. Installation Introduction
User name: MySQL
Installation directory:/usr/local/mysql
Database directory:/usr/local/data/mysql/data
SOURCE Bundle: mysql-5.6.24.tar.gz
2.2. Add Users
Useradd-s/sbin/nologin MySQL
2.3. Create the required catalogue
Mkdir/usr/local/mysql
Mkdir-p/usr/local/data/mysql/data
Chown-r Mysql:mysql/usr/local/data/mysql/data
2.4. Install the necessary files or programs for compiling
Yum install gcc gcc-c++ cmake ncurses-devel Bison
2.5. mysql Download URL
MySQL source package download link http://dev.mysql.com/downloads/mysql/5.7.html
MySQL Reference manual http://dev.mysql.com/doc/
2.6. Compile and install
After downloading the MySQL source package, the source package is in the root directory
Cd/root
TAR-ZXVF mysql-5.6.24.tar.gz
CD mysql-5.6.24
Cmake-dcmake_install_prefix=/usr/local/mysql-dmysql_datadir=/usr/local/data/mysql-ddefault_charset=utf8- Ddefault_collation=utf8_general_ci-dmysql_unix_addr=/tmp/mysql.sock-dwith_myisam_storage_engine=1-denable_ Downloads=1
Make && make install
2.7. After compiling and installing MySQL, add permissions
Chown-r Mysql:mysql/usr/local/mysql
Mv/root/mysql-5.6.24/support-files/mysql-default.conf/etc/my.cnf
mv/root/mysql-5.6.24/support-files/mysql.server/etc/init.d/mysqld
chmod a+x/etc/init.d/mysqld
2.8. Set up MySQL service to boot
Chkconfig--level 345 mysqld on echo "Export Path=/usr/local/mys ql/bin/: $PATH ">>/etc/profile
Source/etc/profile
2.9 Initializing the database
/usr/local/mysql/scripts/mysql_install_db--user=mysql--defaults-file=/etc/my.cnf--basedir=/usr/local/mysql-- Datadir=/usr/local/data/mysql/data
VI/ETC/MY.CNF (Add the following two statements at the end of the file)
Basedir=/usr/local/mysql
Datadir=/usr/local/data/mysql/data
3. Start the database
Service mysqld Start
3.1. Create MySQL Administrator
/usr/local/mysql/bin/mysqladmin-u root password ' 123456 '
-------------------------------------------------------------------------------------------
Start installation below
[begin] 2015/12/18 22:03:34[[email protected] ~]# mkdir -p /usr/local/data/ mysql/data [[email protected] ~]# useradd -s /sbin/nologin mysql [[ email protected] ~]# chown -r mysql:mysql /usr/local/data/mysql/data [[ email protected] ~]# yum install gcc gcc-c++ cmake ncurses-devel bison [[email protected] ~]# tar -zxvf mysql-5.6.24.tar.gz [[email Protected] ~]# cd mysql-5.6.24 [[email protected] mysql-5.6.24]# mkdir /usr/local/mysql [[email protected] mysql-5.6.24]# cmake -dcmake_install_prefix =/usr/local/mysql -dmysql_datadir=/data/mysql/data -ddefault_charset=utf8 -ddefault_ Collation=utf8_general_ci -dmysql_unix_addr=/tmp/mysql.sock -dwith_myisam_storage_engine=1 -denable_downloads=1&nBSP; () [[email protected] mysql-5.6.24]# make [[email protected] mysql-5.6.24]# make install [[email protected] mysql-5.6.24]# chown -r mysql:mysql /usr/local/mysql/ [[email protected] mysql-5.6.24]# mv /root/mysql-5.6.24/ support-files/my-default.cnf /etc/my.cnf [[email protected] mysql-5.6.24]# mv / ROOT/MYSQL-5.6.24/SUPPORT-FILES/MYSQL.SERVER /ETC/INIT.D/MYSQLD[[EMAIL PROTECTED] MYSQL-5.6.24] # chmod a+x /etc/init.d/mysqld[[email protected] mysql-5.6.24]# chkconfig - -level 345 mysqld on[[email protected] mysql-5.6.24]# echo "export path=/usr/local/mysql/bin/: $PATH " >> /etc/profile[[email protected] mysql-5.6.24]# source /etc/profile[[email protected] mysql-5.6.24]# /usr/local/mysql/scripts/mysql_ Install_db --user=mySql --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/usr/local/data/mysql/data [[email protected] mysql-5.6.24]# vi /etc/my.cnf [[email protected] mysql-5.6.24]# service mysqld startstarting mysql... success! [[email protected] mysql-5.6.24]# /usr/local/mysql/bin/mysqladmin -u root password ' 123456 ' [[email protected] mysql-5.6.24]# mysql -u root -p enter password: welcome to the mysql monitor. commands end with ; or \g.Your MySQL connection id is 3Server version: 5.6.24 source distributioncopyright (c) 2000, 2015, Oracle and/or its Affiliates. all rights reserved. Oracle is a registered trademark of oracle corporation and/or itsaffiliates. other names may be trademarks of their Respectiveowners. type ' help; ' or ' \h ' for help. Type ' \c ' to clear the current input statement.mysql> exitbye
MYSQL-5.6.24 Source Package Compilation Installation