標籤:mysql 5.7 mysql 5.7安裝
mysql 5.7最新版本下載
http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.12.tar.gz
在編譯之前,確保已經安裝了epel更新源
安裝了編譯環境
yum groupinstall -y "Development tools"
mysql 5.7編譯cmake要求版本最低為2.8
升級cmake
yum -y install ncurses-devel cmake
mysql 5.7編譯需要boost類庫
:
http://sourceforge.net/projects/boost/files/boost/1.59.0/boost_1_59_0.tar.gz/download
建立使用者和使用者組
groupadd mysql
useradd -g mysql mysql
usermod -s /sbin/nologin mysql
建立目錄
mkdir -p /data/3306/data /data/3306/logs
解壓軟體包
tar zxvf mysql-5.7.12.tar.gz -C /usr/src
cd /usr/src/mysql-5.7.12
編譯
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/3306/data \
-DMYSQL_TCP_PORT=3306 \
-DMYSQL_UNIX_ADDR=/data/3306/mysqld.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_EXTRA_CHARSETS=all \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DEXTRA_CHARSETS=all \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_SSL=bundled \
-DWITH_DEBUG=0 \
-DENABLE_DOWNLOADS=1 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/root/boost_1_59_0.tar.gz
安裝
make
make install
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
在這裡特別提醒,對於mysql5.7的make編譯,如果是雲主機,會在make編譯到45%時會報錯,這是記憶體不足所致
c++: Internal error: Killed (program cc1plus)
Please submit a full bug report.
See <http://bugzilla.redhat.com/bugzilla> for instructions.
make[2]: *** [sql/CMakeFiles/sql.dir/item_geofunc.cc.o] Error 1
make[1]: *** [sql/CMakeFiles/sql.dir/all] Error 2
make: *** [all] Error 2
建立2G的交換分區
dd if=/dev/zero of=/swapfile bs=1k count=2048000 --擷取要增加的2G的SWAP檔案塊
mkswap /swapfile -- 建立SWAP檔案
swapon /swapfile -- 啟用SWAP檔案
swapon -s -- 查看SWAP資訊是否正確
出錯後重新回合組態,需要刪除CMakeCache.txt檔案
make clean
rm -f CMakeCache.txt
重新運行
cmake -DCMAKE_INSTALL_PREFIX**************** 參數
編譯完後, 如果不想要交換分區了, 可以刪除:
swapoff /swapfile
rm -fr /swapfile
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
初始化
/usr/local/mysql/scripts/mysql_install_db \
--basedir=/usr/local/mysql \
--datadir=/data/3306/data \
--user=mysql
編輯設定檔
cd /usr/local/mysql
cp my.cnf my.cnf.bak
vi my.cnf
刪除注視行,添加如下內容:
basedir = /usr/local/mysql
datadir = /data/3306/data
port = 3306
server_id = 2
socket = /data/3306/mysqld.sock
pid-file = /data/3306/mysql.pid
max_allowed_packet=16M
log-error = /data/3306/logs/error.log
設定檔案許可權
chown mysql:mysql -R /data/3306 /usr/local/mysql
複製啟動指令碼
cp /usr/src/mysql-5.6.23/support-files/mysql.server /etc/init.d/mysqld
添加指令碼許可權,加入開機自啟動
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
編輯環境變數
vi /etc/profile
最後一行添加
PATH=$PATH:/usr/local/mysql/bin
重新載入環境變數
source /etc/profile
啟動資料庫
/etc/init.d/mysqld start
初始化
/usr/local/mysql/bin/mysqld --initialize --user=mysql --basedir=/usr/local/mysql --datadir=/data/3306/data
以root初始化操作時要加–user=mysql參數,產生一個隨機密碼(注意儲存登入時用)
2016-05-26T09:30:27.839300Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-05-26T09:30:29.769641Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-05-26T09:30:30.051308Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-05-26T09:30:30.145629Z 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: 7cd43705-2324-11e6-9f04-5254001c11ad.
2016-05-26T09:30:30.153626Z 0 [Warning] Gtid table is not ready to be used. Table ‘mysql.gtid_executed‘ cannot be opened.
2016-05-26T09:30:30.163438Z 1 [Note] A temporary password is generated for [email protected]: &iiaod5Z/f:H
以上資訊可以看到隨機密碼為 &iiaod5Z/f:H
備份設定檔
cd /etc/
mv my.cnf my.cnf.bak
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
編輯設定檔
vi my.cnf
basedir = /usr/local/mysql
datadir = /data/3306/data
port = 3306
server_id = 2
socket = /data/3306/mysqld.sock
pid-file = /data/3306/mysql.pid
max_allowed_packet=16M
log-error = /data/3306/logs/error.log
chown mysql:mysql -R /data/3306 /usr/local/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --level 2345 mysqld on
編輯環境變數
vi /etc/profile
最後一行添加
PATH=$PATH:/usr/local/mysql/bin
重新載入環境變數,啟動mysql
source /etc/profile
/etc/init.d/mysqld start
進入Mysql
mysql -u root -p
輸入密碼: &iiaod5Z/f:H
必須修改密碼,否則提示
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
修改密碼為root
alter user ‘root‘@‘localhost‘ identified by ‘root‘;
quit;
再次進入
mysql -u root -proot
執行命令,就可以了
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)
本文出自 “隕落星空” 部落格,請務必保留此出處http://xiao987334176.blog.51cto.com/2202382/1783509
centos 6.5 x64安裝mysql 5.7