標籤:centos 6.5源碼編譯安裝mysql 5.6
對於伺服器的環境,個人覺得還是源碼編譯安裝的非常靠譜,假如有伺服器要變更,直接rm掉安裝目錄即可。有些人喜歡yum安裝,但是在卸載yum remove的時候,一不小心,就卸載了一個基礎庫,導致系統的shell命令失效,情節嚴重的可能連繫統啟動都會存在問題。
1. 安裝系統的一些必要基礎庫
yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* make cmake bison bison-devel
2. 新增mysql的使用者,並且限制mysql登入,只是作為服務使用者使用而已
#新增使用者組groupadd mysql#新增使用者useradd mysql -g mysql -s /sbin/nologin
3.建立資料庫基礎目錄
#建立資料庫執行檔案目錄mkdir -p /data/mysql-5.6/data/#建立資料庫檔案目錄mkdir -p /data/mysql-5.6# 修改目錄擁有者chown -R mysql:mysql /data/mysql-5.6/data/chown -R mysql:mysql /data/mysql-5.6chown -R mysql:mysql /data/mysql-5.6/data/.chown -R mysql:mysql /data/mysql-5.6/.
4.編譯安裝
vi /etc/profile #在該檔案的末尾,添加 path變數 PATH=/data/mysql-5.6/bin:/data/mysql-5.6/lib:$PATH export PATH #讓配置的path變數生效 source /etc/profile #安裝編譯源碼所需的工具和庫 yum -y install wget gcc-c++ ncurses-devel cmake make perl #進入壓縮包目錄解壓並且編譯 cd /data/src/mysql-5.6.10 cmake -DCMAKE_INSTALL_PREFIX=/data/mysql-5.6 -DMYSQL_UNIX_ADDR=/data/mysql-5.6/tmp/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=/data/mysql-5.6/data -DMYSQL_USER=mysql -DMYSQL_TCP_PORT=3339-DENABLE_DOWNLOADS=1 (出現Googlemock was not found. 加上)-DWITH_DEBUG=0#編譯安裝make && make install#複製開機檔案,以便以後直接services的方式啟動,開機自啟動等。。cp -ar /data/mysql-5.6/support-files/mysql.server /etc/init.d/mysqld#安裝資料庫./scripts/mysql_install_db --user=mysql --datadir=/data/mysql-5.6/data/# 複製設定檔cp -ar /data/mysql-5.6/support-files/my-default.cnf /etc/my.cnf#編輯/etc/my.cnf,修改一下基礎路徑,要不然會出現啟動錯誤。因為我們在編譯的時候填寫預設的安裝目錄和設定檔目錄等等。[mysqld]datadir=/data/mysql-5.6/data/socket=/data/mysql-5.6/tmp/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0[mysqld_safe]log-error=/data/log/mysqld.logpid-file=/data/mysql-5.6/tmp/mysqld.pid#啟動mysqld服務/etc/init.d/mysqld start
到這裡,我們的mysql源碼編譯已經安裝成功了,下面需要我們對資料庫做一些安全性的設定。
刪除資料的test資料庫。
[[email protected] tmp]# mysql -urootWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.10 Source distributionCopyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.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 database test;Query OK, 0 rows affected (0.00 sec)
2.修改資料庫的存取權限。
mysql> select user,password,host from mysql.user;+------+----------+-----------------------+| user | password | host |+------+----------+-----------------------+| root | | localhost || root | | AY140718141902043917Z || root | | 127.0.0.1 || root | | ::1 || | | localhost || | | AY140718141902043917Z |+------+----------+-----------------------+6 rows in set (0.00 sec)#刪除空的賬戶mysql> delete from mysql.user where user=‘‘;Query OK, 2 rows affected (0.00 sec)#建立授權賬戶mysql> grant all privileges on aisk.* ‘tomer‘@‘10.%‘ indentified by ‘HjYk‘ with grant option;
本文出自 “-=湖邊竹=-” 部落格,請務必保留此出處http://bronte.blog.51cto.com/2418552/1441182
CentOS 6.5源碼編譯安裝MySQL 5.6