您好,登錄后才能下訂單哦!
1.MySQL的編譯安裝,需要使用cmake和Boost C++庫(kù),因此在進(jìn)行安裝前,需要提前安裝好cmake及編譯器。
[root@oel6 ~]# yum -y install gcc gcc-c++ ncurses ncurses-devel cmake
2.下載MySQL源代碼,選擇下載Generic Linux (Architecture Independent), Compressed TAR Archive Includes Boost Headers版本,該版本包含boost庫(kù)信息,不需要單獨(dú)下載
[root@oel6 local]# wget http://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-boost-5.7.15.tar.gz
3.添加mysql用戶
[root@oel6 local]# groupadd mysql
[root@oel6 local]# useradd -r -g mysql -s /bin/nologin mysql
4.解壓MySQL安裝介質(zhì)
[root@oel6 local]# tar -zxvf mysql-boost-5.7.15.tar.gz
[root@oel6 local]# cd mysql-5.7.15/
5.編譯安裝MySQL
[root@oel6 local]# mkdir -p /mysql/data
[root@oel6 local]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/mysql/data \
-DWITH_BOOST=/usr/local/mysql-5.7.15/boost/boost_1_59_0 \
[root@oel6 mysql-5.7.15]# make
[root@oel6 mysql-5.7.15]# make install
清除編譯錯(cuò)誤信息
[root@oel6 mysql-5.7.15]# make clean
[root@oel6 mysql-5.7.15]# rm CMakeCache.txt
6.初始化MySQL數(shù)據(jù)庫(kù)
[root@oel6 ~]# cd /usr/local/mysql/
[root@oel6 mysql]# chown -R mysql:mysql ./
[root@oel6 mysql]# bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/mysql/data
2016-10-06T05:11:36.422748Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-06T05:11:36.832157Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-06T05:11:36.900930Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-10-06T05:11:36.961751Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5b4533be-8b83-11e6-927a-0800279bbbbf.
2016-10-06T05:11:36.963090Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-06T05:11:36.964712Z 1 [Note] A temporary password is generated for root@localhost: ;uIY2:ZVrv)u[root@oel6 mysql]# bin/mysql_ssl_rsa_setup --datadir=/mysql/data
Generating a 2048 bit RSA private key
......+++
.........................................................................................................+++
writing new private key to 'ca-key.pem'
-----
Generating a 2048 bit RSA private key
...........................+++
............................................................................................................................................................................................+++
writing new private key to 'server-key.pem'
-----
Generating a 2048 bit RSA private key
.................+++
...........................................................................................................................+++
writing new private key to 'client-key.pem'
-----
MySQL 5.7.6 之前版本,使用下面命令進(jìn)行初始化
bin/mysql_install_db --user=mysql
7.啟動(dòng)MySQL數(shù)據(jù)庫(kù) (編譯安裝的MySQL,會(huì)默認(rèn)創(chuàng)建/etc/my.cnf文件)
[root@oel6 ~]# cd /mysql [root@oel6 mysql]# mkdir log [root@oel6 mysql]# mkdir run [root@oel6 ~]# chown -R mysql:mysql /mysql [root@oel6 mysql]# cat /etc/my.cnf [mysqld] //非默認(rèn)參數(shù)會(huì)影響通過(guò)服務(wù)方式啟停數(shù)據(jù)庫(kù)datadir=/mysql/data user=mysql # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 [mysqld_safe][root@oel6 mysql]# bin/mysqld_safe --user=mysql & [1] 27572 [root@oel6 mysql]# 2016-10-06T05:21:00.684235Z mysqld_safe Logging to '/mysql/log/mysqld.log'. 2016-10-06T05:21:00.709272Z mysqld_safe Starting mysqld daemon with databases from /mysql/data
8.登陸MySQL數(shù)據(jù)庫(kù)
[root@oel6 ~]# vi /root/.bash_profile PATH=$PATH:$HOME/bin:/usr/local/mysql/bin //環(huán)境變量中增加mysql的路徑[root@oel6 ~]# . /root/.bash_profile [root@oel6 mysql]# mysql -u root -h localhost -p Enter password: ;uIY2:ZVrv)uWelcome to the MySQL monitor. Commands end with ; or \g. mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'oracle';
9.配置MySQL服務(wù)自啟動(dòng)
[root@oel6 ~]# cd /usr/local/mysql
[root@oel6 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[root@oel6 mysql]# chkconfig --add mysqld
[root@oel6 mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
10.關(guān)閉MySQL數(shù)據(jù)庫(kù)
[root@oel6 bin]# mysqladmin -u root shutdown
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: NO)'
[root@oel6 bin]# mysqladmin -u root -p shutdown
Enter password:
2016-10-06T05:50:46.469848Z mysqld_safe mysqld from pid file /mysql/run/mysqld.pid ended
[1]+ Done mysqld_safe --user=mysql
11.通過(guò)服務(wù)進(jìn)行MySQL啟停
[root@oel6 bin]# service mysqld start
Starting MySQL. [ OK ]
[root@oel6 bin]# service mysqld stop
Shutting down MySQL. [ OK ]
12.登陸非默認(rèn)端口MySQL
[root@oel6 bin]# mysql -u root -P8000 -h localhost -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g.
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。