Mysql快速配置安裝方法(備)


Mysql5.5安裝配置在Centos上,由於以后有項目要進行幾個架構的探討,所以先自己在虛擬機上測試一套主從,讀寫分離的集群來測試環境!

虛擬機采用的是,vmware workstation8.0,linux:centos5.5版本的!

虛擬機裝系統很簡短就不再截圖出來,網絡采用橋接方式,並且要求能聯網ping通。為了以后更新RPM包使用yum命令,減少依賴包的障礙!

一、安裝cmake

# 安裝所需依賴包
yum -y install gcc libxml2-dev curl screen \
libpng12-dev autoconf libpcre3-dev make bzip2 \
libevent-dev patch libjpeg62-dev libcurl4-openssl-dev \
libfreetype6-dev g++ libtool libncurses5-dev psmisc lrzsz

 

 

同時也要更更新以下的包;

Yum –y install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel*libgcrypt* libtool*

 

# 下載文件
wget
http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz

 

# 編譯安裝
tar zxvf cmake-2.8.5.tar.gz
cd cmake-2.8.5
./boostarp
make
make install
cmake
version

 

這里我把所有的包都存放到/usr/local/這個目錄下,包括下面下載的mysql安裝包;

[root@slave01 local]# ls

bin cmake-2.8.5.tar.gz  etc  games include  lib  libexec sbin  share  src

[root@slave01 cmake-2.8.5]# cmake -version

cmake version 2.8.5

二、 安裝配置mysql

# 下載源文件
wgethttp://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz/from/ftp://ftp.ntu.edu.tw/pub/MySQL/
#

wget ftp://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/mysql-5.5.17.tar.gz

 

以上連個鏈接有問題,大家隨便到網上搜搜,就有很多mysql5.5的安裝包,這個不難。

# 創建用戶和組
groupadd mysql
useradd -g mysql  -s /usr/sbin/nologin  mysql

 

# 創建安裝目錄
mkdir  /usr/local/ mysql

 

# 創建數據庫目錄
mkdir  /usr/local/ mysql/data

 

# 解壓
tar -zxvf mysql-5.5.17.tar.gz
cd mysql-5.5.17

 

# 編譯及安裝mysql
# cmake
編譯: 
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \

-DMYSQL_DATADIR=/usr/local/mysql/data \

-DDEFAULT_CHARSET=utf8 \

-DDEFAULT_COLLATION=utf8_unicode_ci \

-DWITH_READLINE=1 \

-DWITH_SSL=system \

-DWITH_EMBEDDED_SERVER=1 \

-DENABLED_LOCAL_INFILE=1 \

-DDEFAULT_COLLATION=utf8_general_ci \

-DWITH_MYISAM_STORAGE_ENGINE=1 \

-DWITH_INNOBASE_STORAGE_ENGINE=1 \

-DWITH_DEBUG=0

 

運行以后出現以下錯誤;

-- Check size of wchar_t - done

-- Check size of wctype_t

-- Check size of wctype_t - done

-- Check size of wint_t

-- Check size of wint_t - done

-- Found Curses: /usr/lib/libcurses.so

-- Looking for tputs in/usr/lib/libcurses.so

-- Looking for tputs in/usr/lib/libcurses.so - found

-- Looking for include files HAVE_LIBAIO_H

-- Looking for include files HAVE_LIBAIO_H- not found.

-- Looking for io_queue_init in aio

-- Looking for io_queue_init in aio - notfound

-- Performing TestHAVE_IB_GCC_ATOMIC_BUILTINS

-- Performing TestHAVE_IB_GCC_ATOMIC_BUILTINS - Failed

-- Performing TestHAVE_IB_ATOMIC_PTHREAD_T_GCC

-- Performing TestHAVE_IB_ATOMIC_PTHREAD_T_GCC - Failed

-- Check size of pthread_t

-- Check size of pthread_t - done

-- Performing Test HAVE_PEERCRED

-- Performing Test HAVE_PEERCRED - Success

Warning: Bisonexecutable not found in PATH

-- Configuring incomplete, errors occurred!

You have mail in /var/spool/mail/root

安裝下bison包,

Yum –y install bison*

再次運行出現新錯誤,不要着急,遇到錯誤,應該是很欣慰,現在知道了,以后就有把握自己處理,不必再百度,谷歌,滿世界詢問了

[root@slave01 mysql-5.5.13]# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1-DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1-DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0

-- MySQL 5.5.13

-- checking for module 'openssl'

--   package 'openssl' notfound

-- Could NOT find OpenSSL, try to set thepath to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR(missing:  OPENSSL_LIBRARIESOPENSSL_INCLUDE_DIR)

CMake Error at cmake/ssl.cmake:83(MESSAGE):

 Cannot find appropriate system libraries for SSL.  Use WITH_SSL=bundled to

 enable SSL support

Call Stack (most recent call first):

 CMakeLists.txt:248 (MYSQL_CHECK_SSL)

 

 

-- Configuring incomplete, errors occurred!

此錯誤提示很清楚,有個包缺少,yum下即可。遇錯誤一定仔細看錯誤信息,這是你成為牛人的關鍵一步;

[root@slave01 mysql-5.5.13]# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data-DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_READLINE=1-DWITH_SSL=system -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1-DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0

-- MySQL 5.5.13

-- checking for module 'openssl'

--  found openssl, version 0.9.8e-rhel5

-- Found OpenSSL:/usr/lib/libssl.so;/usr/lib/libcrypto.so (found version "0.9.8")

CMake Error at cmake/ssl.cmake:83(MESSAGE):

 Cannot find appropriate system libraries for SSL.  Use WITH_SSL=bundled to

 enable SSL support

Call Stack (most recent call first):

 CMakeLists.txt:248 (MYSQL_CHECK_SSL)

我裝好包以后再次運行,依然有err出現,這里是因為,我們在多次運行的時候cmake有個文件我們需要刪除,需要在安裝新包的情況下,重新應用下相關的文件;

刪除當前目錄CMakeCache.txt並重新運行:

Cmake .

看清楚有個點,並且有個空格;

再次運行cmake命令就會正常;

 

 

# 安裝mysql
make && make install

 

 

# 復制配置文件
cp support-files/my-medium.cnf  /etc/my.cnf

 

# 設置權限
chmod +x /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql

chown -Rmysql:mysql /usr/local/mysql/data

 

# 配置開機自啟動
cp support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
chkconfig –add mysqld

chkconfig mysqldon

 

# 修改my.cnf配置
vim /etc/my.cnf

# [mysqld] 添加:
datadir=/usr/local/mysql/data
default-storage-engine=MyISAM

 

# 以下可選:
log-error =/usr/local/mysql/data/error.log
pid-file = /usr/local/mysql/data/mysql.pid
user = mysql
tmpdir = /tmp

 

# 初始化數據庫
/usr/local/mysql/scripts/mysql_install_db --user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &

 

# 啟動MySQL
/usr/local/mysql/bin/mysqld_safe –defaults-file=/etc/my.cnf &

或者:
/etc/init.d/mysql start (service mysql start)

 

 

# 測試MySQL是否啟動

# 1)查看是否有進程mysql
ps -ef | grep mysql

# 2)查看端口是否運行
netstat -tnl | grep 3306

# 3)讀取mysql版本信息
/usr/local/mysql/bin/mysqladmin version

 

# 至此,MySQL安裝完成

 

 

安裝的mysql的root密碼一般都是空,我們可以設置它為我們指定的密碼;

首先登陸mysql,然后執行下面命令即可;

SET PASSWORD FOR 'root'@'localhost' =PASSWORD('your new password');

flush privileges;


注意!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。



 
粤ICP备14056181号  © 2014-2021 ITdaan.com