添加mysql組和mysql用戶
[root@test mysql]# groupadd mysql
[root@test mysql]# useradd -g mysql mysql
編譯與安裝
tar -zxvf mysql-5.1.35.tar.gz
./configure /
–prefix=/usr/local/mysql /
–localstatedir=/data/mysql/data / mysql數據目錄
–enable-assembler /
–with-mysqld-ldflags=-rdynamic /
–with-client-ldflags=-all-static /
–with-plugins=innobase,partition /
–with-extra-charsets=none /
–enable-thread-safe-client /
–with-client-ldflags=-all-static / 以純靜態方式編譯客戶端
–with-mysqld-ldflags=-all-static 以純靜態方式編譯服務端
make && make install
–enable-thread-safe-client /以線程方式編譯客戶端
mysql目錄權限設置
mkdir /usr/local/mysql/var
mkdir /var/run/mysqld
chmod +w /usr/local/mysql/
chown -R mysql:mysql /usr/local/mysql/
chown -R mysql:mysql /var/run/mysqld
cp /usr/local/mysql/share/mysql/my-innodb-heavy-4G.cnf /etc/my.cnf
以mysql用戶初始化數據庫表
/usr/local/mysql/bin/mysql_install_db –basedir=/usr/local/mysql –datadir=/data/mysql/data –user=mysql
–datadir=/data/mysql/data 定義mysql數據存放目錄
註意:如果把數據目錄定義到其它目錄裡,得先修改/etc/my.cnf文件,加上以下二行
[mysqld]
# generic configuration options
port = 3306
socket = /tmp/mysql.sock
# wb config
basedir = /usr/local/mysql 字義mysql程序目錄
datadir = /data1/mysql/data 定義數據目錄
在對數據庫進行初始化表,不然mysql數據庫啟動會報錯.
啟動mysql服務
/usr/local/mysql/bin/mysqld_safe –user=mysql –datadir=/data/mysql/data (指定數據庫目錄)
/usr/local/mysql/bin/mysqld_safe –user=mysql 2>&1 > /dev/null &
本文出自 “vkey24” 博客