標籤:
MySQL 5.5(5.6)後版本,需要使用cmake(Cross make , https://cmake.org/ )編譯
我的環境如下:
VMWare虛擬機器,CentOS 5.5 x86_64(核心:2.6.18-194.el5),SecureCRT用戶端
第一步:安裝開發環境
[[email protected] ~]# yum groupinstall "Development Libraries" -y
第二步:準備cmake源碼包/MySQL源碼包
[[email protected] ~]# mkdir /app/soft -p
[[email protected] ~]# cd /app/soft
[[email protected] soft]# rz
[[email protected] soft]# ls
cmake-3.3.2.tar.gz mysql-5.6.26.tar.gz
現在看到的 cmake-3.3.2.tar.gz 是 cmake 源碼壓縮包,可以在 https://cmake.org/download 下載到。
mysql-5.6.26.tar.gz 為:http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.26.tar.gz
個人建議cmake,下載2.8版本的,地址:http://www.cmake.org/files/v2.8/cmake-2.8.10.2.tar.gz
解壓源碼包
[[email protected] soft]# tar xf cmake-3.3.2.tar.gz
[[email protected] soft]# ls
cmake-3.3.2.tar.gz mysql-5.6.26.tar.gz
cmake-3.3.2 mysql-5.6.26
第三步:編譯並安裝cmake
[[email protected] soft]# cd cmake-3.3.2
[[email protected] cmake-3.3.2]# ls
Auxiliary CMakeLogo.gif CTestConfig.cmake Modules
bootstrap cmake_uninstall.cmake.in CTestCustom.cmake.in README.rst
CMakeCPack.cmake CompileFlags.cmake DartConfig.cmake Source
CMakeCPackOptions.cmake.in configure doxygen.config Templates
CMakeGraphVizOptions.cmake CONTRIBUTING.rst Help Tests
CMakeLists.txt Copyright.txt Licenses Utilities
[[email protected] cmake-3.3.2]#
[[email protected] cmake-3.3.2]# ./configure
當然除了使用源碼編譯安裝外,還可以 yum install cmake -y 方式進行安裝。
這一步,我折騰了很久。最後實在沒辦法,卸載3.3版本的cmake,重新安裝2.8版本,終於各種奇葩的問題就沒了、
第四步:建立MySQL資料庫目錄
我新加了一個SISC介面的磁碟來作為mysql的資料盤用的、
[[email protected] ~]# fdisk /dev/sdb
The number of cylinders for this disk is set to 2610.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (1826-2610, default 1826):
Using default value 1826
Last cylinder or +size or +sizeM or +sizeK (1826-2610, default 2610): +20G
Command (m for help): w
[[email protected] ~]# mke2fs -j /dev/sdb2
[[email protected] ~]# mkdir /mydata/ # 建立sdb2的掛在目錄
[[email protected] ~]# vim /etc/fstab # 磁碟自動掛載
/dev/VolGroup00/LogVol00 / ext3 defaults 1 1
LABEL=/boot /boot ext3 defaults 1 2
tmpfs /dev/shm tmpfs defaults 0 0
devpts /dev/pts devpts gid=5,mode=620 0 0
sysfs /sys sysfs defaults 0 0
proc /proc proc defaults 0 0
/dev/VolGroup00/LogVol01 swap swap defaults 0 0
/dev/sdb2 /mydata ext3 defaults 0 0
[[email protected] ~]# mount -a
[[email protected] ~]# mkdir /mydata/data -p
小提示:在SecureCRT在fdisk命令如果輸錯參數,退格無法刪除輸入字元,請使用ctrl+退格
第五步:建立MySQL使用者,組,屬組授權
[[email protected] soft]# groupadd -r mysql
[[email protected] soft]# useradd -r -g mysql -s /sbin/nologin mysql
[[email protected] soft]# chown -R mysql.mysql /mydata/data
第六步:編譯MySQL(cmake . -LH , make && make install)
[[email protected] soft]# cmake . -LH
[[email protected] soft]# cmake . -DDATA_DIR=/mydata/data # 設定mysql資料庫存放目錄為第四步建立的目錄,有其它參數可以在這裡設定
關於cmake,可以參考下這裡:http://www.ttlsa.com/mysql/configure-to-cmake/
[[email protected] soft]# make && make install
第七步:配置MySQL(mysql安裝目錄屬組/MySQL初始化指令碼)
[[email protected] soft]# cd /usr/local/mysql
[[email protected] mysql]# chown -R :mysql /usr/local/mysql # 將mysql安裝目錄的屬組設定為mysql
[[email protected] mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
Installing MySQL system tables...
OK
...........其它資訊忽略了...............
第八步:配置MySQL(編輯設定檔,mysqld服務開機自啟)
[[email protected] mysql]# cp support-files/my-default.cnf /etc/my.cnf
[[email protected] mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[[email protected] mysql]# chkconfig --add mysqld # 添加到開機自啟服務列表
[[email protected] mysql]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] mysql]# service mysqld start
Starting MySQL.... [OK] # 不容易啊,安裝完成了,o(∩_∩)o ~~
第九步:登入MySQL
[[email protected] mysql]# ls
bin data include lib my.cnf README share support-files
COPYING docs INSTALL-BINARY man mysql-test scripts sql-bench
[[email protected] mysql]# mysql # 我已經把 /usr/local/mysql/bin 加入了PATH,但輸入 mysql 登入時候得到下面的錯誤
mysql: error while loading shared libraries: libmysqlclient.so.15: cannot open shared object file: No such file or directory
[[email protected] mysql]# bin/mysql # 換種方式,直接用 bin/mysql ,注意哦。全路徑其實是 /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, 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> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
第十步:簡單的安全設定(刪除匿名使用者,修改密碼)
mysql> drop user ‘‘@localhost; // localhost 為主機名稱。或者可以直接修改修改掉所有使用者的密碼
mysql> update mysql.user set password=password(‘[email protected]‘) where user=‘root‘; // 修改密碼
mysql> flush privileges; // 重新整理、重新載入許可權
mysql> quit;
Bye
[[email protected]]# bin/mysql
ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
[[email protected]]# bin/mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, 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>
新加一個允許【用戶端IP地址為:10.0.0.1;使用者名稱:ocean;密碼:123456的mysql使用者】
mysql> insert into mysql.user(
mysql> host,user,password,ssl_cipher,x509_issuer,x509_subject )
mysql> values(‘10.0.0.1‘,‘ocean‘,password(‘123456‘),‘‘,‘‘,‘‘) ;
參數資料:http://blog.chinaunix.net/uid-20577907-id-3082601.html
注意了哦(ssl_cipher,x509_issuer,x509_subject,這三個欄位。我在寫入mysql.user表時候提示沒有預設值,才加了這三個欄位,一般只需要host,user,password 就可以了、)
來一張10.0.0.1用戶端通過Navicat串連到資料的。
第十一步:本地不輸入密碼串連到MySQL(在使用者家目錄下,編輯一個 .my.cnf)
[[email protected] ~]# vi .my.cnf
[client]
user=root
host=localhost
[email protected]
[[email protected] ~]# /usr/local/mysql/bin/mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 17
Server version: 5.6.26 Source distribution
Copyright (c) 2000, 2015, 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>
-----------------------------------------------------------------------------------------------------
啊哈,筆記終於完成了咯。
溫馨提示、再提供了一個對 剪貼簿圖片輕鬆儲存的 小工具。有興趣的園友試試看。
輕鬆儲存您剪貼簿中的到任意目錄。【支援ctrl+v快捷】,不妨看看,或許你用到了呢?~
http://www.cnblogs.com/oceanho/p/4714204.html
Linux編譯安裝與配置-MySQL(5.5,5.6)版本系(筆記)