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.
# Wgethttp: // www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
#Tarzxvfcmake-2.8.4.tar.gz
# Cdcmake-2.8.4
#./Configure
# Make
# Makeinstall
2. Make sure that the following system software packages are installed:
Run the rpm-qa | grepname 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-yinstall, or find it directly from the system installation disc and install it using rpm-ivh.
3. system settings before installation
Create the mysql installation directory and data storage directory
# Mkdir/opt/mysql
# Mkdir/opt/mysql/data
Create users and user groups
# Groupaddmysql
# Useradd-gmysqlmysql
Grant the data storage directory permission
# Chownmysql: mysql-R/opt/mysql/data
4. Change from configure to cmake
I believe that most people are used to the configure method and the parameters used are more personalized. After changing to cmake, this will cause a lot of trouble.
Fortunately, the MySQL official website provides a parameter comparison table between the two. We can keep the previous parameters as much as possible to compile and configure the new MySQL version.
Configure and cmake parameters:
Http://forge.mysql.com/wiki/Autotools_to_CMake_Transition_Guide
Take myself as an example. The parameters that I used previously 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-Cycler \
-- 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 comparison with cmake parameters, most of the canceled parameters are removed because the new version is enabled by default. The cmake parameter configuration is 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 MySQL5.5.x
By using.
# Wgethttp: // mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.13.tar.gz
#Tarzxvfmysql-5.5.13.tar.gz
# Cdmysql-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
# Makeinstall
The percentage of progress can be seen in make and makeinstall, which is better than configure.
6. Configure and initialize the database
Create my. cnf configuration file
# Mkdir/opt/mysql/log
# Mkdir/opt/mysql/etc
# Cpsupport-files/my-medium.cnf/opt/mysql/etc/my. cnf
Initialize Database
Grant the execution permission to the scripts/mysql_install_db file before execution.
# Chmod755scripts/mysql_install_db
# Scripts/mysql_install_db -- user = mysql -- basedir =/opt/mysql/-- datadir =/opt/mysql/data/
Create shell scripts for MySQL Database Management
# Mkdir/opt/mysql/init. d
# Cpsupport-files/mysql. server/opt/mysql/init. d/mysql
Grant the shell script executable permission:
# Chmod + x/opt/mysql/init. d/mysql
Start MySQL:
#/Opt/mysql/init. d/mysqlstart
Log on to the MySQL server through the command line and press Enter when prompted to enter the password ):
#/Opt/mysql/bin/mysql-uroot-p-S/tmp/mysql. sock
Enter the following SQL statement to create a user admin with the root permission) and password 12345678 ):
GRANTALLPRIVILEGESON *. * TO 'admin' @ 'localhost' IDENTIFIEDBY '123 ';
GRANTALLPRIVILEGESON *. * TO 'admin' @ '2017. 0.0.1 'IDENTIFIEDBY '20160301 ';
Set the initial password for the root account
#/Opt/mysql/bin/mysqladmin-urootpassword 'new-password'
Deletes an empty password account for an anonymous connection to the local machine.
/Opt/mysql/bin/mysql-uroot-p 'new-password'
Mysql> usemysql; // select the system database mysql
Mysql> selectHost, User, Passwordfromuser; // view all users
Mysql> deletefromuserwherepassword = "";
Mysql> flushprivileges;
Mysql> selectHost, User, Passwordfromuser; // check whether all users whose passwords are empty have been deleted.
Mysql> exit;
This article is from the "linux technology column" blog, please be sure to keep this source http://sangh.blog.51cto.com/6892345/1300895