error
http://www.phperz.com/article/14/1208/39937.html
一.准备
测试软件 mysql-5.5.36
系统版本 CentOS release 6.5 (Final) 64bit
----------------------------------------------------------------------------------
|实例 |端口 |data位置 |配置文件 |启动文件 |
----------------------------------------------------------------------------------
|mysql3306|3306 |/data/mysql_3306| /etc/my3306.cnf |/etc/init.d/mysql.server3306 |
----------------------------------------------------------------------------------
|mysql3307|3307 |/data/mysql_3307| /etc/my3307.cnf |/etc/init.d/mysql.server3307 |
----------------------------------------------------------------------------------
下载软件包
一般放在 /opt/mysql里
wget http://downloads.mysql.com/archives/get/file/mysql-5.5.36.tar.gz
tar -zxvf mysql-5.5.36.tar.gz
yum -y install cmake
yum -y install gcc gcc-c++ autoconf automake zlib* fiex* libxml* ncurses-devel libmcrypt* libtool-ltdl-devel* cmake cmake-gui libaio-devel bision
(诺出现Error: Missing Dependency: kernel-headers glibc装不上)
http://vault.centos.org/5.8/os/x86_64/CentOS/kernel-headers-2.6.18-308.el5.x86_64.rpm
下载wget http://vault.centos.org/5.7/os/x86_64/CentOS/kernel-headers-2.6.18-274.el5.x86_64.rpm
安装rpm -ivh kernel-headers-2.6.18-274.el5.x86_64.rpm
http://blog.sina.com.cn/s/blog_8f27abe50101204l.html
创建用户
groupadd mysql
useradd -g mysql -s /sbin/nologin -M mysql
创建安装目录,授权用户
mkdir -p /data/mysql5536
chown -R mysql:mysql /data/
二.安装
解压安装(设定安装默认位置为/data/mysql5536)
cd /opt/mysql/mysql-5.5.36
cmake . -DCMAKE_INSTALL_PREFIX=/data/mysql5536 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DENABLED_LOCAL_INFILE=1
make && make install
如果这里编译失败,请删除CMakeCache.txt。再安装晚依赖在重新cmake。否则会一直提示错误。
三.数据库文件(创建实例)
初始化数据库
/data/mysql5536/scripts/mysql_install_db --basedir=/data/mysql5536/ --datadir=/data/mysql_3306 --user=mysql
创建my.cnf文件
cp my.cnf my3306.cnf
vi /data/mysql_3306/my.cnf
[client]
port = 3306 #默认3306
socket = /data/mysql_3306/mysql.sock
[mysqld]
port = 3306
socket = /data/mysql_3306/mysql.sock
datadir=/data/mysql_3306
user=mysql
wait_timeout=1814400
interactive_timeout=1814400
lower_case_table_names=1
expire-logs-days = 1
skip-name-resolve
[mysqld_safe]
log-error=/data/mysql_3306/mysqld.log
pid-file=/data/mysqld_3306/mysqld.pid
记得这里将实例的路径拥有者修改为mysql
chown -R mysql:mysql /data/mysql_3306
四.启动数据库
启动该数据库实例
cp /data/mysql5536/support-files/mysql.server /etc/init.d/mysql.server3306
vi /etc/init.d/mysql.server3306
将默认的conf=/etc/my.cnf
修改为 conf=/etc/my3306.cnf
打开数据库
/etc/init.d/mysql.server3306 start|stop|restart
#/data/mysql5536/bin/mysqld_safe --defaults-extra-file=/data/mysql_3306/my.cnf --datadir=/data/mysql_3306 --user=mysql &
关闭数据库实例
五.多实例的安装
使用第三步在创建另外一个实例 假如另外一个实例是监听3307端口
1)初始化这个实例数据库
/data/mysql5536/scripts/mysql_install_db --basedir=/data/mysql5536/ --datadir=/data/mysql_3307 --user=mysql
2)创建该实例的my.cnf文件
vi /etc/my3307.cnf
[client]
port = 3307 #默认3306
socket = /data/mysql_3307/mysql.sock
[mysqld]
port = 3307
socket = /data/mysql_3307/mysql.sock
port = 3306
socket = /data/mysql_3307/mysql.sock
datadir=/data/mysql_3306
wait_timeout=1814400
interactive_timeout=1814400
lower_case_table_names=1
expire-logs-days = 1
skip-name-resolve
记得这里将实例的路径拥有者修改为mysql
chown -R mysql:mysql /data/mysql_3307
3)启动该实例 同上面第四步
cp /data/mysql5536/support-files/mysql.server /etc/init.d/mysql.server3307
vi /etc/init.d/mysql.server3307
将默认的conf=/etc/my.cnf
修改为 conf=/etc/my3307.cnf
打开数据库
/etc/init.d/mysql.server3307 start|stop|restart
进入指定数据库
mysql -uroot -p -S /data/mysql_3306/mysql.sock
grant all privileges on *.* to ‘admin‘@‘%‘ identified by ‘123456‘;
grant all privileges on *.* to ‘admin‘@‘locatehost‘ identified by ‘123456‘;
参考文档
http://blog.chinaunix.net/uid-25760152-id-3472603.html