[LAMP]Mysql-5.6.28編譯安裝

梓沐發表於2016-02-15
環境引數:Linux:Centos6.5,cmake:3.3.2,mysql:5.6.28

1.下載cmake,下載地址:wget --no-check-certificate

2.安裝cmake
tar xf cmake-3.3.2.tar.gz
cd cmake-3.3.2
./configure
gmake && gmake install

3.下載mysql,下載地址:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.28.tar.gz

4.新增mysql使用者和組
groupadd mysql
useradd mysql -s /sbin/nologin -M -g mysql

5.安裝ncurses-devel
yum install ncurses-devel -y

6.解壓mysql
tar xf mysql-5.6.28.tar.gz
cd mysql-5.6.28

7.編譯mysql
cmake . -DCMAKE_INSTALL_PREFIX=/application/mysql-5.6.28 \
-DMYSQL_DATADIR=/application/mysql-5.6.28/data \
-DMYSQL_UNIX_ADDR=/application/mysql-5.6.28/tmp/mysql.sock \
-DEXTRA_CHARSETS=gbk,gb2312,utf8,ascii \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_FAST_MUTEXES=1 \
-DWITH_ZLIB=bundled \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_READLINE=1 \
-DWITH_EMBEDDED_SERVER=1 \
-DWITH_DEBUG=0

注:如果make到63%左右出現錯誤:
make[2]: * [storage/perfschema/unittest/pfs_connect_attr-t] Error 1
make[1]: * [storage/perfschema/unittest/CMakeFiles/pfs_connect_attr-t.dir/all] Error 2

則:cmake去掉-DWITH_PARTITION_STORAGE_ENGINE=1引數重新編譯

8.mysql安裝
make && make install

9.做軟連線
ln -s /application/mysql-5.6.28/ /application/mysql

10.mysql目錄授權
chown -R mysql:mysql /application/mysql-5.6.28/

11.相關檔案
cd /application/mysql/support-files
cp my-default.cnf /etc/my.cnf
cp mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld

12.mysql初始化
cd /application/mysql/scripts/
./mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql

13.啟動mysql
/etc/init.d/mysqld start

14.配置環境變數
echo 'export PATH=/application/mysql/bin:$PATH'>>/etc/profile
source /etc/profile

15.登陸mysql,刪除無用配置,只保留如下,並刪除test資料庫
mysql> select user,host from mysql.user;
+------+-----------+
| user | host      |
+------+-----------+
| root | 127.0.0.1 |
| root | localhost |
+------+-----------+
mysql> drop database test;

16.配置登陸密碼
/application/mysql//bin/mysqladmin -u root password 'cancer'

17.設定mysql開機啟動
chkconfig mysqld on
chkconfig --list mysqld

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29812844/viewspace-1988850/,如需轉載,請註明出處,否則將追究法律責任。

相關文章