這篇文章主要為大家展示了“MySQL 8.0如何實現(xiàn)源碼編譯安裝”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領(lǐng)大家一起研究并學(xué)習(xí)一下“Mysql 8.0如何實現(xiàn)源碼編譯安裝”這篇文章吧。
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)!專注于網(wǎng)頁設(shè)計、網(wǎng)站建設(shè)、微信開發(fā)、微信小程序定制開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了江干免費(fèi)建站歡迎大家使用!
路徑:https://dev.mysql.com/downloads/mysql/
這里選擇 mysq-8.0.16.tar.gz
##查詢
rpm -qa | grep mysql rpm -qa | grep maria
##清理(如果存在的話)
yum remove mysql
##或者
yum remove mariadb
yum -y install gcc gcc-c++ ncurses ncurses-devel libaio-devel openssl openssl-devel
編譯的時候,分別錯誤提示:
CMake 3.4.3 or higher is required.
GCC 5.3 or newer is required
所以需要安裝Cmake和GCC的相關(guān)版本
請參考: http://blog.itpub.net/69915315/viewspace-2648182
tar -zxvf tar -zxvf mysql-8.0.16.tar.gz
(1) 進(jìn)入目錄 mysql-8.0.16 ,建立一個目錄,用于存放編譯好的軟件
cd mysql-8.0.16 mkdir xiaochong
(2) 進(jìn)入子目錄xiaochong,進(jìn)行編譯前的配置。 主要cmake后是 . . , 執(zhí)行其父目錄。
cd xiaochong
配置參數(shù):
cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DENABLED_LOCAL_INFILE=ON \ -DWITH_INNODB_MEMCACHED=ON \ -DWITH_SSL=system \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_FEDERATED_STORAGE_ENGINE=1 \ -DWITH_BLACKHOLE_STORAGE_ENGINE=1 \ -DWITH_ARCHIVE_STORAGE_ENGINE=1 \ -DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \ -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \ -DCOMPILATION_COMMENT="xiaochong edition" \ -DDOWNLOAD_BOOST=1 \ -DWITH_BOOST=/usr/local/boost \ -DCMAKE_CXX_COMPILER=/usr/bin/g++ \ -DWITH_BOOST=/tmp
make -j 10
make install
末尾如下提示,表示成功。
-- Configuring done
-- Generating done
-- Build files have been written to: /software/mysql-8.0.16/xiaochong
--------------------------------------------------------------------------------------------------
錯誤1 c++: error: unrecognized command line option ‘-std=c++14’
解決方式: 添加: -DCMAKE_CXX_COMPILER=/usr/bin/g++
groupadd mysql useradd -g mysql mysql
mkdir -p /data/mysql/{3306,3307}/{data,log,tmp,innodb,innodb_log}
這里是兩個實例的目錄,分別是3306和3307.
創(chuàng)建后,目錄結(jié)構(gòu)如下:
[root@mysql80 /]# cd data
[mysql@mysql80 data]$ tree .
.
└── mysql
├── 3306
│ ├── data
│ ├── innodb
│ ├── innodb_log
│ ├── log
│ └── tmp
└── 3307
├── data
├── innodb
├── innodb_log
├── log
└── tmp
chown -R mysql:mysql /data/mysql/ chown -R mysql:mysql /usr/local/mysql/
echo 'export PATH=$PATH:/usr/local/mysql/bin' >> /etc/profile source /etc/profile
(1)3306
vim /data/mysql/3306/my3306.cnf
內(nèi)容如下:
[client] port=3306 socket=/data/mysql/3306/mysql.sock [mysqld] port=3306 user=mysql socket=/data/mysql/3306/mysql.sock pid-file=/data/mysql/3306/mysql.pid basedir=/usr/local/mysql datadir=/data/mysql/3306/data tmpdir=/data/mysql/3306/tmp open_files_limit=60000 #explicit_defaults_for_timestamp server-id=3306 lower_case_table_names=1 character-set-server=utf8 #federated #sql_mode=STRICT_TRANS_TABLES max_connections=1000 max_connect_errors=100000 interactive_timeout=86400 wait_timeout=86400 sync_binlog=0 back_log=100 default-storage-engine=InnoDB log_slave_updates=1 #*********** Logs related settings *********** log-bin=/data/mysql/3306/log/mysql3306-bin binlog_format=mixed binlog_cache_size=32m max_binlog_cache_size=64m max_binlog_size=512m long_query_time=1 log_output=FILE log-error=/data/mysql/3306/log/mysql-error.log slow_query_log=1 slow_query_log_file=/data/mysql/3306/log/slow_statement.log #log_queries_not_using_indexes general_log=0 general_log_file=/data/mysql/3306/log/general_statement.log #expire-logs-days = 14 binlog_expire_logs_seconds=1728000 relay-log=/data/mysql/3306/log/relay-bin relay-log-index=/data/mysql/3306/log/relay-bin.index #****** MySQL Replication New Feature********* master-info-repository=TABLE relay-log-info-repository=TABLE #relay-log-recovery #*********** INNODB Specific options *********** innodb_buffer_pool_size=2048M transaction-isolation=REPEATABLE-READ innodb_buffer_pool_instances=8 innodb_file_per_table=1 innodb_data_home_dir=/data/mysql/3306/innodb innodb_data_file_path=ibdata1:2048M:autoextend innodb_thread_concurrency=8 innodb_log_buffer_size=16M innodb_log_file_size=128M innodb_log_files_in_group=3 innodb_log_group_home_dir=/data/mysql/3306/innodb_log innodb_flush_log_at_trx_commit=2 innodb_max_dirty_pages_pct=70 innodb_flush_method=O_DIRECT [mysql] no-auto-rehash default-character-set=gbk prompt = (\u@\h) [\d]>\_
(1)3307
vim /data/mysql/3307/my3307.cnf
內(nèi)容如下:
[client] port=3307 socket=/data/mysql/3307/mysql.sock [mysqld] port=3307 user=mysql socket=/data/mysql/3307/mysql.sock pid-file=/data/mysql/3307/mysql.pid basedir=/usr/local/mysql datadir=/data/mysql/3307/data tmpdir=/data/mysql/3307/tmp open_files_limit=60000 #explicit_defaults_for_timestamp server-id=3307 lower_case_table_names=1 character-set-server=utf8 #federated #sql_mode=STRICT_TRANS_TABLES max_connections=1000 max_connect_errors=100000 interactive_timeout=86400 wait_timeout=86400 sync_binlog=0 back_log=100 default-storage-engine=InnoDB log_slave_updates=1 #*********** Logs related settings *********** log-bin=/data/mysql/3307/log/mysql3306-bin binlog_format=mixed binlog_cache_size=32m max_binlog_cache_size=64m max_binlog_size=512m long_query_time=1 log_output=FILE log-error=/data/mysql/3307/log/mysql-error.log slow_query_log=1 slow_query_log_file=/data/mysql/3307/log/slow_statement.log #log_queries_not_using_indexes general_log=0 general_log_file=/data/mysql/3307/log/general_statement.log #expire-logs-days = 14 binlog_expire_logs_seconds=1728000 relay-log=/data/mysql/3307/log/relay-bin relay-log-index=/data/mysql/3307/log/relay-bin.index #****** MySQL Replication New Feature********* master-info-repository=TABLE relay-log-info-repository=TABLE #relay-log-recovery #*********** INNODB Specific options *********** innodb_buffer_pool_size=2048M transaction-isolation=REPEATABLE-READ innodb_buffer_pool_instances=8 innodb_file_per_table=1 innodb_data_home_dir=/data/mysql/3307/innodb innodb_data_file_path=ibdata1:2048M:autoextend innodb_thread_concurrency=8 innodb_log_buffer_size=16M innodb_log_file_size=128M innodb_log_files_in_group=3 innodb_log_group_home_dir=/data/mysql/3307/innodb_log innodb_flush_log_at_trx_commit=2 innodb_max_dirty_pages_pct=70 innodb_flush_method=O_DIRECT [mysql] no-auto-rehash default-character-set=gbk prompt = (\u@\h) [\d]>\_
(1) 3306
mysqld --defaults-file=/data/mysql/3306/my3306.cnf --initialize --user=mysql
(2) 3307
mysqld --defaults-file=/data/mysql/3307/my3307.cnf --initialize --user=mysql
錯誤如下:
[mysql@mysql80 ~]$ mysqld --defaults-file=/data/mysql/3306/my.cnf --initialize --user=mysql
mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by mysqld)
mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by mysqld)
mysqld: /lib64/libstdc++.so.6: version `CXXABI_1.3.8' not found (required by mysqld)
mysqld: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by mysqld)
解析辦法:
原因: 由于我們之前升級了gcc,也就是gcc-5.3.0. 但目錄 /lib64/ 下的庫文件鏈接的是 libstdc++.so.6 依然軟鏈接是低版本 libstdc++.so.6.0.19
[root@mysql80 /]# cd /lib64/
[root@mysql80 lib64]# ls -l | grep libstdc++.so.6
lrwxrwxrwx. 1 root root 19 Jun 19 14:36 libstdc++.so.6 -> libstdc++.so.6.0.19
-rwxr-xr-x. 1 root root 991616 Apr 24 22:24 libstdc++.so.6.0.19
進(jìn)入到新安裝的gcc-5.3.0的目錄,進(jìn)入lib64,查看libstdc++.so.6,軟鏈接的是 libstdc++.so.6.0.21
[root@mysql80 gcc-5.3.0]# cd lib64/
[root@mysql80 lib64]# ls -l | grep libstdc++.so.6
lrwxrwxrwx. 1 root root 19 Jun 25 15:54 libstdc++.so -> libstdc++.so.6.0.21
lrwxrwxrwx. 1 root root 19 Jun 25 15:54 libstdc++.so.6 -> libstdc++.so.6.0.21
-rwxr-xr-x. 1 root root 11089328 Jun 25 15:54 libstdc++.so.6.0.21
處理: 刪除原來的軟鏈接,建立新的軟鏈接:
[root@mysql80 lib64]# rm -rf libstdc++.so.6
[root@mysql80 lib64]# ln -s /usr/local/gcc-5.3.0/lib64/libstdc++.so.6 libstdc++.so.6
[root@mysql80 lib64]# ls -l | grep libstdc++.so.6
lrwxrwxrwx. 1 root root 41 Jun 26 14:48 libstdc++.so.6 -> /usr/local/gcc-5.3.0/lib64/libstdc++.so.6
(1) 3306
/mysqld_safe --defaults-file=/data/mysql/3306/my.cnf --user=mysql &
(2)3307
/mysqld_safe --defaults-file=/data/mysql/3307/my.cnf --user=mysql &
這里以3306實例為例,3307步驟相同,只需要注意端口號即可,即大寫的 -P
(1)查找root@localhost的初始密碼,
查看當(dāng)前錯誤日志
more /data/mysql/3306/log/mysql-error.log
找到如下行,標(biāo)紅的即是密碼:
[MY-010454] [Server] A temporary password is generated for root@localhost: ?/ihz.ew8SIy
mysql -uroot -p'?/ihz.ew8SIy' -P3306 -S /data/mysql/3306/mysql.sock
(2)登錄
mysql -uroot -p'?/ihz.ew8SIy' -P3306 -S /data/mysql/3306/mysql.sock
(3)修改密碼
ALTER USER 'root'@'localhost' IDENTIFIED WITH sha256_password BY 'Yxc@3306' PASSWORD EXPIRE INTERVAL 360 DAY;
(4) 查詢數(shù)據(jù)庫
ysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
以上是“Mysql 8.0如何實現(xiàn)源碼編譯安裝”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!