轉載自 http://www.cnblogs.com/littlehb/archive/2013/04/02/2995007.htmlhtml
Mysql 5.5之後使用了CMake進行安裝,參考與之前的區別請參考:java
http://www.blogjava.net/kelly859/archive/2012/09/04/387005.html
mysql
接上文。linux
1:下載:當前mysql版本到了5.6.17c++
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gzsql
2:必要軟件包數據庫
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison bison-develapp
# 新增用戶組
groupadd mysqlsocket
# 新增用戶
useradd mysql -g mysqlide
# 新建數據庫執行文件目錄
mkdir -p /usr/local/mysql
# 新建數據庫數據文件目錄
mkdir -p /db/mysql/data
# 修改目錄擁有者
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /db/mysql/data
chown -R mysql:mysql /usr/local/mysql/.
chown -R mysql:mysql /db/mysql/data/.
# 編輯PATH搜索路徑
vi /etc/profile
添加以下兩行:
PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:$PATH
export PATH
# 生效PATH搜索路徑
source /etc/profile
# 安裝編譯源碼所需的工具和庫
yum -y install wget gcc-c++ ncurses-devel cmake make perl
# 進入源碼壓縮包下載目錄
cd /usr/src
# 下載源碼壓縮包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
# 解壓縮源碼包
tar -zxv -f mysql-5.6.17.tar.gz
# 進入解壓縮源碼目錄
cd mysql-5.6.17
# 編譯並安裝
複製代碼
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DMYSQL_DATADIR=/db/mysql/data \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306
-DENABLE_DOWNLOADS=1(出現Googlemock was not found. 加上)
-DWITH_DEBUG=0
make && make install
紅色部分表示禁用Debug模式。
複製代碼
# 複製配置文件
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
# 進入安裝路徑
cd /usr/local/mysql
# 執行配置腳本
scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data
# 複製服務啓動腳本
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
# 啓動MySQL服務
service mysql start
# 設置開機自動啓動服務
chkconfig mysql on
#添加系統變量
echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profile
echo "export PATH" >> /etc/profile
source /etc/profile
>>>>>>>>>>>>>>>完成
若是發生以下錯誤:
[root@rekfan mysql]# service mysql restart
MySQL server PID file could not be found![失敗]
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/rekfan.pid).[失敗]
黃海的問題解決辦法是:
killall命令
killall命令殺死同一進程組內的全部進程。其容許指定要終止的進程的名稱,而非PID。
# killall mysqld
再次查看mysqld進程:
ps -ef|grep mysqld
沒有了!世界清靜了。
運行 mysql
而後進入mysql> 提示符後,輸入status;
查看安裝狀況。
複製代碼
mysql> status;
--------------
mysql Ver 14.14 Distrib 5.6.10, for Linux (x86_64) using EditLine wrapper
Connection id: 1
Current database:
Current user: root@localhost
SSL: Not in use
Current pager: stdout
Using outfile: ''
Using delimiter: ;
Server version: 5.6.10 Source distribution
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset: latin1
Db characterset: latin1
Client characterset: latin1
Conn. characterset: latin1
UNIX socket: /tmp/mysql.sock
Uptime: 7 sec
Threads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.714
--------------
複製代碼
#表名所有爲小寫,避免出現大小寫敏感
vi /etc/my.cnf 添加以下內容,解決大小寫表名敏感問題。
lower_case_table_names=1
修改MySQL的root用戶的密碼以及打開遠程鏈接
mysql
mysql> use mysql;
複製代碼
mysql> desc user;
mysql> GRANT ALL PRIVILEGES ON *.* TO root@"%" IDENTIFIED BY "root"; //爲root添加遠程鏈接的能力
mysql> update user set Password = password('123456') where User='root'; //設置root用戶密碼
mysql> select Host,User,Password from user where User='root';
mysql> flush privileges;
mysql> exit
複製代碼
附自動安裝腳本以下:
vi installmysql.sh
chmod 777 installmysql.sh
./installmysql.sh
內容以下:
複製代碼
yum -y install wget gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake perl bison bison-devel
groupadd mysql
useradd mysql -g mysql
mkdir -p /usr/local/mysql
mkdir -p /db/mysql/data
chown -R mysql:mysql /usr/local/mysql
chown -R mysql:mysql /db/mysql/data
chown -R mysql:mysql /usr/local/mysql/.
chown -R mysql:mysql /db/mysql/data/.
echo "PATH=/usr/local/mysql/bin:/usr/local/mysql/lib:\$PATH" >> /etc/profile
echo "export PATH" >> /etc/profile
source /etc/profile
cd /usr/software/
#下載mysql源碼包
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.17.tar.gz
tar -zxvf mysql-5.6.17.tar.gz
cd /usr/software/mysql-5.6.17
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1 -DMYSQL_DATADIR=/db/mysql/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3306
make && make install
cp /usr/local/mysql/support-files/my-default.cnf /etc/my.cnf
cd /usr/local/mysql
scripts/mysql_install_db --user=mysql --datadir=/db/mysql/data
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql
echo "lower_case_table_names=1" >> /etc/my.cnf
service mysql start
chkconfig mysql on
mysqladmin -u root password 'dsideal'
service iptables stop
chkconfig iptables off
sed -i 's#SELINUX=enforcing#SELINUX=disabled#'g /etc/sysconfig/selinux