Source code Compilation Install MySQL 5.5.x Practice
1. Installing CMake
MySQL has been removed from version 5.5, and is replaced by the CMake tool./configure.
Therefore, we first need to compile and install the CMake tool in the system source code.
# wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
# tar ZXVF cmake-2.8.4.tar.gz
# CD cmake-2.8.4
#./configure
# make
# make Install
2. Ensure that the following required system packages have been installed
by Rpm-qa | grep name verifies that the following packages are all installed.
gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libgcrypt* libtool*
If a related package is missing, it can be installed online via yum-y install, or directly from the system installation CD and installed by RPM-IVH.
3. Pre-installation system settings
Build MySQL installation directory and data storage directory
# Mkdir/opt/mysql
# Mkdir/opt/mysql/data
Create users and user groups
# Groupadd MySQL
# useradd-g MySQL MySQL
Assigning permissions to the data store directory
# chown Mysql:mysql-r/opt/mysql/data
4. Change from Configure to CMake
I believe that most people are accustomed to the previous configure way, and the parameters used are more personalized, after switching to CMake, which will bring a lot of trouble.
Fortunately, MySQL's official website provides a comparison of the two parameters, we can keep the previous parameters as far as possible, to compile the configuration of the new MySQL version.
Configure and CMake parameter comparison guide:
Http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
In my case, the parameters I've been using before are:
./configure--prefix=/opt/mysql/\
--SYSCONFDIR=/OPT/MYSQL/ETC \
--localstatedir=/opt/mysql/data \
--with-tcp-port=3306 \
--with-unix-socket-path=/tmp/mysqld.sock \
--with-mysqld-user=mysql \
--enable-assembler \
--with-extra-charsets=all \
--enable-thread-safe-client \
--with-big-tables \
--with-readline \
--WITH-SSL \
--with-embedded-server \
--enable-local-infile \
--with-plugins=partition,innobase,myisammrg
After comparing the parameters with CMake, remove the parameters that have been canceled (mostly because the new version is already enabled by default), and the CMake parameters are configured as follows:
Cmake-dcmake_install_prefix=/opt/mysql \
-DSYSCONFDIR=/OPT/MYSQL/ETC \
-dmysql_datadir=/opt/mysql/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
5. Compile and install MySQL 5.5.x
Download the package via the Http://www.mysql.com/downloads/mysql official website or the domestic Sohu image, such as the current MySQL 5.5.13.
# wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.13.tar.gz
# tar ZXVF mysql-5.5.13.tar.gz
# CD mysql-5.5.13
# cmake-dcmake_install_prefix=/opt/mysql \
-DSYSCONFDIR=/OPT/MYSQL/ETC \
-dmysql_datadir=/opt/mysql/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
# make
# make Install
You can see the percentage of progress when you install make and make, which feels better than the Configure method.
6. Configure and initialize the database
Create a MY.CNF configuration file
# Mkdir/opt/mysql/log
# MKDIR/OPT/MYSQL/ETC
# CP SUPPORT-FILES/MY-MEDIUM.CNF/OPT/MYSQL/ETC/MY.CNF
Initializing the database
Need to assign scripts/mysql_install_db file execution permissions before execution
# chmod 755 scripts/mysql_install_db
# scripts/mysql_install_db--user=mysql--basedir=/opt/mysql/--datadir=/opt/mysql/data/
Create a shell script that manages the MySQL database
# MKDIR/OPT/MYSQL/INIT.D
# CP Support-files/mysql.server/opt/mysql/init.d/mysql
To give the shell script executable permissions:
# chmod +x/opt/mysql/init.d/mysql
Start MySQL:
#/opt/mysql/init.d/mysql Start
Log in to manage the MySQL server via the command line (enter directly when prompted for the password):
#/opt/mysql/bin/mysql-u Root-p-s/tmp/mysql.sock
Enter the following SQL statement to create a user with root privileges (admin) and password (12345678):
GRANT all privileges on * * to ' admin ' @ ' localhost ' identified by ' 12345678 ';
GRANT all privileges on * * to ' admin ' @ ' 127.0.0.1 ' identified by ' 12345678 ';
Set the initial password for the root account
#/opt/mysql/bin/mysqladmin-u root password ' new-password '
Remove the empty password account for the native anonymous connection
/opt/mysql/bin/mysql-uroot-p ' New-password '
Mysql>use MySQL; Select System Database MySQL
Mysql>select Host,user,password from User; View All Users
Mysql>delete from user where password= "";
Mysql>flush privileges;
Mysql>select Host,user,password from User; Confirm that a user with a blank password has been completely deleted
mysql>exit;
Installation configuration for MySQL