A Download the installation package
Since compiling and installing MySQL requires CMake, compile and install CMake, and download it all together.
- Download CMake, url https://cmake.org/download/
- Download MySQL, url http://dev.mysql.com/downloads/mysql/here to log in to the Oracle user name password
Two Compiling and installing CMake
Unzip the cmake, such as TAR-ZXVF cmake-3.5.0.tar.gz, into the main directory CD cmake-3.5.0
Here you can see some of the contents and files, here can be installed with bootstrap or congfigure to install, here we use./bootstrap to install, because./configure is not adding environment variables
That's when we find that C + + dependencies are missing.
Install compile all dependencies
Yum-y install gcc gcc-c++ ncurses-devel perl
Execute again./bootstrap detects the compilation environment without any exceptions after compiling gmake && gmake Install
Three CMake compiling and installing MYSQL1. Compiling and installing
First unpack MySQL for example command TAR-ZXVF mysql-5.6.29.tar.gz
Go to home directory CD mysql-5.6.29/
To execute a compile command
CMake \
-dcmake_install_prefix=/usr/local/mysql \
-dmysql_unix_addr=/usr/local/mysql/mysql.sock \
-ddefault_charset=utf8 \
-DDEFAULT_COLLATION=UTF8_GENERAL_CI \
-dwith_innobase_storage_engine=1 \
-dwith_archive_storage_engine=1 \
-dwith_blackhole_storage_engine=1 \
-dmysql_datadir=/opt/sxt/data/mysql \
-dmysql_tcp_port=3306 \
-denable_downloads=1
Note that the data directory in the above command needs to be created in advance mkdir-p/opt/sxt/data/mysql
Execute compile command make (compile) && make install (install)
After the installation is complete, we can find that MySQL is installed in the/usr/local/mysql directory,
2. Initializing the database
scripts/mysql_install_db--user=root--datadir=/opt/sxt/data/mysql
Found an anomaly.
Here you need to modify the configuration file vim/etc/my.cnf
If it is the older version here is no/etc/my.cnf need to be copied from the installation location.
Attention:
CP /usr/local/mysql/support-files/my-default.cnf/etc /my.cnf
Change the contents into:
[Mysqld]
Port = 3306
Socket =/usr/local/mysql/mysql.sock
Basedir =/usr/local/mysql
DataDir =/opt/sxt/data/mysql/
Pid-file =/opt/sxt/data/mysql/slave1.pid
user = root
Here, MySQL is changed to root.
Re-executing the initialization script
scripts/mysql_install_db--user=root--datadir=/opt/sxt/data/mysql
3. Configure the Startup service
CP Support-files/mysql.server/etc/init.d/mysqld
Vim/etc/profile
path=/usr/Local/mysql/bin:/usr/local/mysql/lib: $PATH
Export PATH
Make the configuration file take effect immediately
Source/etc/profile
4. Login
Mysql-uroot–p then enter the password
If you can't connect, mysql-u root-p
5. Modify the MySQL user name password
mysqladmin-u root password ' 123456 '
MySQL compilation installation under Linux