CentOs7 64位 mysql 5.6.40原始碼安裝過程
1.首先安裝依賴包,避免在安裝過程中出現問題
[[email protected] yusen]# yum -y install wget vim bash-completion [[email protected] yusen]# yum -y install gcc gcc-c++ cmake ncurses-devel autoconf perl perl-devel
2.下載mysql-5.6.40.tar.gz
MySQLxxx下載地址: https://dev.mysql.com/downloads/mysql/5.6.html#downloads
原始碼包地址: https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40.tar.gz
[[email protected] yusen]# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.40.tar.gz [[email protected] yusen]# ls mysql-5.6.40.tar.gz
3.建立mysql安裝目錄以及資料存放目錄
[[email protected] yusen]# mkdir -p /usr/local/mysql/data
4.建立使用者、使用者組
[[email protected] yusen]# groupadd mysql [[email protected]yusen]# useradd -r -g mysql mysql
5.解壓縮檔案到當前資料夾及安裝
[[email protected] yusen]# tar -zxvf mysql-5.6.40.tar.gz [[email protected] yusen]# cd mysql-5.6.40 [[email protected] mysql-5.6.40]# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DINSTALL_DATADIR=/usr/local/mysql/data \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DEXTRA_CHARSETS=all \ -DENABLED_LOCAL_INFILE=1 [[email protected] mysql-5.6.40]# make && make install
CMAKE引數說明:
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //預設安裝目錄
-DINSTALL_DATADIR=/usr/local/mysql/data //資料庫存放目錄
-DDEFAULT_CHARSET=utf8 //使用utf8字元
-DDEFAULT_COLLATION=utf8_general_ci //校驗字元
-DEXTRA_CHARSETS=all //安裝所有擴充套件字符集
-DENABLED_LOCAL_INFILE=1 //允許從本地匯入資料
-DMYSQL_USER=mysql
-DMYSQL_TCP_PORT=3306
CMAKE詳細配置請參照mysql官網
注意事項:
如安裝失敗重新編譯時,需要清除舊的物件檔案和快取資訊。
[[email protected] mysql-5.6.40]# make clean [[email protected] mysql-5.6.40]# rm -f CMakeCache.txt [[email protected] mysql-5.6.40]# rm -rf /etc/my.cnf
6.設定目錄許可權
[[email protected] yusen]# cd /usr/local/mysql [[email protected] mysql]# chown -R mysql:mysql . [[email protected] mysql]# chown -R mysql:mysql data
7.將mysql的啟動服務新增到系統服務中
[[email protected] yusen]# cd /usr/local/mysql [[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
8.建立基礎表
[[email protected] yusen]# cd /usr/local/mysql [[email protected] mysql]# ./scripts/mysql_install_db --user=mysql
9.配置環境變數(新增下面兩條)
[[email protected] yusen]# vim /etc/profile export MYSQL_HOME="/usr/local/mysql" export PATH="$PATH:$MYSQL_HOME/bin" **#載入環境變數** [[email protected] yusen]# source /etc/profile
10.將mysql啟動檔案新增到系統啟動檔案中
[[email protected] yusen]# cd /usr/local/mysql/ [[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysql
11.mysql的 啟動 停止 及 重啟命令
啟動mysql服務
[[email protected] yusen]# systemctl start mysql
重啟mysql服務
[[email protected] yusen]# systemctl restart mysql
停止mysql服務
[[email protected] yusen]# systemctl stop mysql
開機自啟
[[email protected] yusen]# systemctl enable mysql
或者:
啟動mysql服務
[[email protected] yusen]# service mysql start
重啟mysql服務
[[email protected] yusen]# service mysql restart
停止mysql服務
[[email protected] yusen]# service mysql stop
將服務新增到開機啟動指令管理的服務列表中
chkconfig --add mysql
開機自啟
chkconfig mysql on
12.修改mysql密碼
[[email protected] yusen]# mysqladmin -u root password New password: Confirm new password: [[email protected] yusen]#
13.連線 Mysql
[[email protected] yusen]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.40 Source distribution Copyright (c) 2000,2016,Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
在此mysql-5.6.40原始碼安裝就完成了
總結
以上所述是小編給大家介紹的CentOs7 64位 mysql 5.6.40原始碼安裝過程,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回覆大家的。在此也非常感謝大家對我們網站的支援!
如果你覺得本文對你有幫助,歡迎轉載,煩請註明出處,謝謝!