CentOS 6.6 source code compilation and installation MySQL 5.7.18 tutorial details, centos5.7.18
1. Add users and groups
1. Add a mysql user group
# groupadd mysql
2. Add a mysql user
# useradd -g mysql -s /bin/nologin mysql -M
2. Check whether mysql is installed in the system. If the installation needs to be uninstalled
# rpm -qa | grep mysqlmysql-libs-5.1.73-3.el6_5.x86_64# rpm -e mysql-libs-5.1.73-3.el6_5.x86_64 --nodeps
3. Install the required dependent package
# yum -y install wget gcc-c++ ncurses-devel cmake
Iv. Installation
1. download the latest MySQL version.
Go to http://dev.mysql.com/downloads/mysql/and select Generic Linux under source Code. Select mysql download with boost library. MySQL5.7 has requirements on boost libraries. If you select boost libraries, you will avoid some pitfalls.
# Wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-boost-5.7.18.tar.gz
2. Unzip and install
# tar xf mysql-boost-5.7.18.tar.gz# cd mysql-5.7.18# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306 -DWITH_BOOST=boost/boost_1_59_0# make && make install
MySQL will be installed in the/usr/local/mysql directory.
3. Go to the installation directory and create the data directory.
# cd /usr/local/mysql# mkdir data
4. Modify/usr/local/mysql Directory Permissions
# chown -R mysql. /usr/local/mysql
5. initialize the database
# ./mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
Note:
1. in earlier versions, mysql_install_db was stored in mysql_basedir/script, 5.7 was stored in the mysql_install_db/bin directory, and has been deprecated.
2. "-- initialize" will generate a random password (~ /. Mysql_secret), and "-- initialize-insecure" will not generate a password
3. -- data files cannot be found in the target datadir directory.
4. After the -- initialize parameter is used, remember the generated password. Otherwise, you cannot log on to the database.
6. Copy the Startup File to/etc/init. d/and run the command mysqld again.
# /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
7. Create a configuration file
No my. cnf configuration file is found after installation. manually create one
# vim /etc/my.cnf[mysqld]basedir =/usr/local/mysqldatadir =/usr/local/mysql/dataport = 3306socket = /tmp/mysql.sock[client]socket=/tmp/mysql.sock
8. Start mysql
# /etc/init.d/mysqld start
9. log on to mysql
#/Usr/local/mysql/bin/mysql-uroot-p password generated by the system
10. Modify the root password
Mysql> set password = password ('new password'); mysql> flush privileges; mysql> exit
11. log out and log on again
#/Usr/local/mysql/bin/mysql-uroot-p 'new password'
The above is a detailed explanation of the CentOS 6.6 source code compilation and installation MySQL 5.7.18 tutorial. I hope it will be helpful to you. If you have any questions, please leave a message for me, the editor will reply to you in a timely manner. Thank you very much for your support for the help House website!