mysql5.6的安裝(cmake)
從官網下載了一個最新版的mysql原始碼包mysql-5.6.4-m7.tar.zip,準備安裝一下,可是解壓出來,卻發現無法./configure。後來才知道mysql現在用cmake了。
這裡貼一下cmake編譯安裝mysql的方法:
下載cmake的source包:wget
一 安裝cmake
如果本機上不存在cmake,則:
./bootstrap
make -----有時候是gmake
make install
如果本機上存在cmake,想安裝一個新版本,則:
cmake .
make
make install
(皮愛死:bootstrap不是通用程式。只要知道是安裝指令碼就行了。具體的用法看各自的README、install之類的文件。這裡看的就是 Readme.txt。但裡面說是執行make;make install,但是bootstrap之後提示資訊是執行gmake,那就先gmake唄。gmake和make的區別請看另一篇文章《gmake和 make》。)
export PATH=/usr/local/cmake/bin:$PATH (如果已經能找到cmake命令就不用這步了)
二 安裝mysql5.6
1、建立使用者、組
groupadd mysql
useradd mysql -g mysql
2 安裝
#cd mysql-5.6.4-m7
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
-DMYSQL_DATADIR=/usr/local/mysql/demo
-DWITH_MYISAM_STORAGE_ENGINE=1
-DWITH_INNOBASE_STORAGE_ENGINE=1
-DWITH_ARCHIVE_STORAGE_ENGINE=1
-DWITH_BLACKHOLE_STORAGE_ENGINE=1
-DENABLED_LOCAL_INFILE=1
-DDEFAULT_CHARSET=utf8
-DDEFAULT_COLLATION=utf8_general_ci
-DEXTRA_CHARSETS=all
-DMYSQL_TCP_PORT=3306
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysqld.sock
-DSYSCONFDIR=/usr/local/mysql/etc/my.cnf
-DWITH_DEBUG=0
部分引數說明詳見http://blog.samxy.com/archives/287.html 下面摘一點:
-DCMAKE_INSTALL_PREFIX= 資料庫程式安裝路徑;
-DMYSQL_DATADIR= 資料庫檔案存放路徑(不配置的話會預設建立$PREFIX_DIR/data)
-DMYSQL_UNIX_ADDR= 預設位置是/tmp/mysql.sock
-DDEFAULT_CHARSET= 預設資料庫編碼
-DDEFAULT_COLLATION= 預設資料庫整理編碼
-DWITH_EXTRA_CHARSETS= 擴充套件支援編碼(all | utf8,gbk,gb2312 | none)
-DWITH_MYISAM_STORAGE_ENGINE= MYISAM引擎支援(1|0)
-DWITH_INNOBASE_STORAGE_ENGINE= innoDB引擎支援(1|0)
-DWITH_MEMORY_STORAGE_ENGINE= MEMORY引擎支援(1|0)
shell> make
shell> make install
四、配置mysql
1、修改配置檔案my.cnf
chmod 775 /tmp/
cp support-files/my-medium.cnf /usr/local/mysql/my.cnf
修改my.cnf引數,沒有則加入如下:
basedir = /usr/local/mysql(不配置的話預設為$PREFIX_DIR)
datadir = /usr/local/mysql/demo(不配置的話預設為$PREFIX_DIR/data)
log-error = /usr/local/mysql/mysql_error.log(不配置的話預設為$PREFIX_DIR/data/$hostname.err)
pid-file = /usr/local/mysql/mysql.pid(不配置的話預設為$PREFIX_DIR/data/$hostname.pid)
tmpdir = /tmp(不配置的話預設為/tmp)
2、初始化安裝:
chmod +x scripts/mysql_install_db
scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/demo --user=mysql
(--user一定要加,其他可不加,預設會是$PREFIX_DIR和$PREFIX_DIR/data,因為--help看到說不加--user會以當前系統登入使用者啟動mysql)
成功後有如下提示:
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/src/mysql/bin/mysqladmin -u root password 'new-password'
/usr/local/src/mysql/bin/mysqladmin -u root -h localhost password 'new-password'
Alternatively you can run:
/usr/local/src/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/src/mysql ; /usr/local/src/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/src/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /usr/local/src/mysql/scripts/mysqlbug script!
修改資料目錄的許可權
shell> chown -R root:mysql mysql
shell> chown -R mysql :mysql demo
3 可以根據現在螢幕上的提示資訊來做,先啟動mysql:
/usr/local/mysql/bin/mysqld_safe --user=mysql & //啟動mysql 等同於/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/my.cnf --user=mysql & 因為/usr/local/mysql是basedir 所以前面啟動省略了
/usr/local/mysql/bin/mysqladmin --version //測試下
4 再修改root密碼:
/usr/local/mysql/bin/mysqladmin -u root password 'abc123.'
測試是否能進入:
/usr/local/mysql/bin/mysql -u root -p
可以進入,好的,殺掉程式,接著做下面的。
將mysql加入開機啟動:
cp support-files/mysql.server /etc/init.d/mysqld (如果已有/etc/init.d/mysqld也要複製下,因為自帶的mysqld裡面控制服務的方式與原始碼中帶的mysqld不同,而且還要重新定 義下面提到要修改的欄位)
chmod +x /etc/init.d/mysqld
修改上面檔案的如下欄位:
basedir=/usr/local/mysql
datadir=/usr/local/mysql/data
mysqld_pid_file_path=/var/run/mysqld
其實上面三個定義為空的話也沒事,因為下面會有一個判斷將這兩個變數定義為my.cnf中我們定義的值(5.5.28版本中有這個判斷,其他版本我不知道有沒有,到時候注意下)。
然後執行:
chkconfig--add mysqld
chkconfig--level 345 mysqld on
3、啟動mysql
/etc/init.d/mysqld start
總結:這次安裝極其坑爹,注意每一步執行之後要看提示資訊以及錯誤日誌,有很多有用資訊,可以少走很多彎路!!
補充 5.7安裝需要注意的
- 參考文件http://blog.itpub.net/29733787/viewspace-1590891/
- cmake時報錯
-
CMake Error at cmake/boost.cmake:76 (MESSAGE):
You can download it with -DDOWNLOAD_BOOST=1 -DWITH_BOOST=
- 解決辦法一:
-
[root@Lnmp mysql-5.7.9]# cmake 。。。 -DDOWNLOAD_BOOST=1 -DWITH_BOOST=/usr/local/boost --最後面加這兩個引數(下載並安裝boost的意思)
解決辦法二:
下載 安裝boost_1_59_0.tar.gz
[root@host-192-168-2-177 ~]# mkdir /usr/local/boost/
[root@host-192-168-2-177 ~]# cd /usr/local/boost/
[root@host-192-168-2-177 ~]# tar -zxvf boost_1_59_0.tar.gz
[root@host-192-168-2-177 ~]# cd boost_1_59_0
[root@host-192-168-2-177 ~]#./bootstrap.sh
[root@host-192-168-2-177 ~]#./b2 install
再cmake成功
[root@Lnmp mysql-5.7.9]# cmake 。。。
有可能缺失
5.7初始化資料庫
/usr/local/mysql5.7/bin/mysqld --initialize --basedir= --datadir= --user=mysql
mysql5.7會生成一個初始化密碼,而在之前的版本首次登陸不需要登入。
[root@localhost bin]# ./mysqld --initialize --basedir=/soft/mysql-5.7.11-linux-glibc2.5-x86_64 --datadir=/soft/mysql-5.7.11-linux-glibc2.5-x86_64/data --user=mysql 2016-01-10T14:15:18.467542Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details). 2016-01-10T14:15:19.739479Z 0 [Warning] InnoDB: New log files created, LSN=45790 2016-01-10T14:15:20.232923Z 0 [Warning] InnoDB: Creating foreign key constraint system tables. 2016-01-10T14:15:20.834849Z 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: 9514acfc-b7a4-11e5-918a-0800272b8253. 2016-01-10T14:15:20.850238Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened. 2016-01-10T14:15:20.871908Z 1 [Note] A temporary password is generated for root@localhost: ICSPgCF%l5Q4
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29096438/viewspace-1412209/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- ubuntu安裝CMakeUbuntu
- CMake的安裝和使用
- (CMake):CMake安裝及快速入門案例
- Linux安裝Mysql5.6LinuxMySql
- Docker Centos安裝Mysql5.6DockerCentOSMySql
- CentOS下安裝配置cmakeCentOS
- Mysql-5.5.32 cmake安裝MySql
- CMAKE安裝mysql5.5MySql
- windows安裝cmake、opencv、qtWindowsOpenCVQT
- MySQL 5.7.17 安裝報錯CMake Error at cmake/boost.cmake:81 (MESSAGE)MySqlError
- CentOS6.5下MySQL5.6的安裝CentOSMySql
- Linux上yum安裝mysql5.6LinuxMySql
- MySQL5.6 windows msi安裝介紹MySqlWindows
- CentOS6.5上安裝MySQL5.6CentOSMySql
- MySQL5.6 linux原始碼安裝MySqlLinux原始碼
- Windows下CMake編譯安裝OpenCVWindows編譯OpenCV
- MYSQL 5.6 安裝時cmake引數MySql
- 在VMware已安裝的CentOS7.9上編譯安裝mysql5.6CentOS編譯MySql
- mysql在linux上cmake安裝方法(自己安裝版)MySqlLinux
- Mysql5.6壓縮包安裝到windows&& 解除安裝命令MySqlWindows
- ubuntu mysql5.6二進位制安裝UbuntuMySql
- MySQL之——RPM方式安裝MySQL5.6MySql
- Linux下MySQL5.6原始碼安裝LinuxMySql原始碼
- 在CentOS 6.3中安裝與配置cmakeCentOS
- CentOS 6 下RPM方式安裝MySQL5.6CentOSMySql
- linux 環境RPM 安裝MYSQL5.6LinuxMySql
- MySQL5.6 audit審計外掛安裝初探MySql
- MySQL5.6一鍵編譯安裝指令碼MySql編譯指令碼
- Linux環境MySQL5.6安裝實踐LinuxMySql
- Centos64位6.3 下安裝 Mysql5.6CentOSMySql
- CMake 學習【七】—— 生成一個安裝器
- linux mysql5.6版本的安裝配置過程LinuxMySql
- Mysql5.6 for Centos6.5原始碼編譯安裝MySqlCentOS原始碼編譯
- LEMP環境搭建及配置(三)安裝MySQL5.6MySql
- CentOS6.3安裝lnmp(php5.4,mysql5.6)CentOSLNMPPHPMySql
- Mysql安裝過程中CMAKE編譯出錯MySql編譯
- MySQL 5.5編譯安裝cmake引數說明MySql編譯
- Linux 安裝 mysql 5.5.8(cmake原始碼安裝mysql5.5以上版本)[轉]LinuxMySql原始碼