说明:
操作系统:CentOS 6.6 64位
MySQL版本:mysql-5.6.24
MySQL安装目录:/opt/mysql55
MySQL数据库存放目录:/opt/mysql55/data
1、下载MySQL
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz
2、安装编译工具及库文件(使用CentOS yum命令安装,安装的比较多,方便以后编译安装php、nginx等)
yum install cmake autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libpng* ncurses* libtool* libxml2 libxml2-devel bison -y
3、安装MySQL
groupadd mysql #添加mysql组
useradd -g mysql mysql #创建用户mysql并加入到mysql组
mkdir -p /opt/mysql55 #创建MySQL安装目录
cd /usr/local/src #进入软件包存放目录
tar zxvf mysql-5.6.24.tar.gz #解压
cd mysql-5.6.24 #进入目录
***********************************补充************************************
4、编译参数简介
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mysql55 \ #设置安装目录
-DMYSQL_DATADIR=/opt/mysql55/data \ #设置数据库存放目录
-DSYSCONFDIR=/etc \ #设置my.cnf所在目录,默认为安装目录
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #添加MYISAM引擎支持
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #添加InnoDB引擎支持
-DWITH_MEMORY_STORAGE_ENGINE=1 \ #添加MEMORY支持
-DWITH_PARTITION_STORAGE_ENGINE=1 \ #添加PARTITION支持
-DWITH_READLINE=1 \ #加载readline库
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ #设置UNIX socket 目录
-DMYSQL_TCP_PORT=3306 \ #设置服务器监听端口,默认3306
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DEXTRA_CHARSETS=all \ #安装所有扩展字符集
-DDEFAULT_CHARSET=utf8 \ #设置默认字符集,默认latin1
-DDEFAULT_COLLATION=utf8_general_ci #设置默认校对规则,默认latin1_general_ci
***************************************************************************
#配置
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -
DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -
DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
#更多编译的参数可以参考
#http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
#http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
#编译
make
#安装
make install
cd /opt/mysql55 #进入MySQL安装目录
./scripts/mysql_install_db --user=mysql --basedir=/u01/mysql --datadir=/u01/mysql/data/ #初始化,生成msql系统数据库
cp ./support-files/mysql.server /etc/init.d/mysqld #把Mysql加入系统服务
chmod 755 /etc/init.d/mysqld #增加执行权限
chkconfig mysqld on #加入开机启动
service mysqld start #启动
=======
可能会启动失败:Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/mysql.top.pid).
1、/u01/mysql 目录的权限 改成mysql
chown -R mysql:mysql /u01/mysql/
2、
rpm -qa | grep -i mysql
rpm -e mysql-libs --nodeps
==========================
#把mysql服务加入系统环境变量:在最后添加下面这一行
vim /etc/profile
export PATH=$PATH:/u01/mysql/bin
mysqladmin -u root -p password "123456" #或者直接修改密码
service mysqld restart #重启
*******************************************************************
MySQL多实例安装
*******************************************************************
#建立data2、data3
[root@www mysql55]# pwd
/opt/mysql55
[root@www mysql55]# ll
total 196
drwxr-xr-x 2 root root 4096 Apr 27 04:48 bin
-rw-r--r-- 1 root root 17987 Mar 26 00:34 COPYING
drwxr-xr-x. 5 mysql mysql 4096 Apr 27 08:55 data
drwxr-xr-x 5 mysql mysql 4096 Apr 27 08:20 data2
drwxr-xr-x 5 mysql mysql 4096 Apr 27 08:25 data3
#初始化,生成mysql系统数据库
./scripts/mysql_install_db --user=mysql --basedir=/opt/mysql55 --datadir=/opt/mysql55/data2
./scripts/mysql_install_db --user=mysql --basedir=/opt/mysql55 --datadir=/opt/mysql55/data3
#修改my.cnf
[mysqld_multi]
mysqld =/opt/mysql55/bin/mysqld_safe
mysqladmin =/opt/mysql55/bin/mysqladmin
user =test
password =test
[mysqld3306]
basedir = /opt/mysql55
datadir = /opt/mysql55/data
port = 3306
pid-file=/tmp/mysql3306.pid
server-id=1
socket = /tmp/mysql3306.sock
[mysqld3307]
basedir = /opt/mysql55
datadir = /opt/mysql55/data2
port = 3307
pid-file=/tmp/mysql3307.pid
server-id=1
socket = /tmp/mysql3307.sock
[mysqld3308]
basedir = /opt/mysql55
datadir = /opt/mysql55/data3
port = 3308
pid-file=/tmp/mysql3308.pid
server-id=1
socket= /tmp/mysql3308.sock
[client]
port =3306
socket =/tmp/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#启动
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf start 3306 #3307、3308同样
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf statr 3306-3308 #亦可同时启动
#关闭
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 3306
ps -ef|grep 3306 #发现进程还存在
#查看/mysql55/share/mysqld_multi.log 日志
Warning: Using a password on the command line interface can be insecure.
/opt/mysql55/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'test'@'localhost' (using password: YES)'
#由于在my.cnf配置文件设置了test用户、密码
[mysqld_multi]
mysqld =/opt/mysql55/bin/mysqld_safe
mysqladmin =/opt/mysql55/bin/mysqladmin
user =test
password =test
**************
cd /tmp/
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:25 mysql3306.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:28 mysql3307.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:30 mysql3308.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:13 mysql.sock
-rw-------. 1 root root 0 Apr 11 23:18 yum.log
#登陆数据库
[root@www tmp]# mysql -S ./mysql3306.sock
#
mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
#授权并赋予test密码
mysql> grant shutdown on *.* to test@localhost identified by "test" with grant option;
Query OK, 0 rows affected (0.00 sec)
即可成功关闭3306
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 3306
操作系统:CentOS 6.6 64位
MySQL版本:mysql-5.6.24
MySQL安装目录:/opt/mysql55
MySQL数据库存放目录:/opt/mysql55/data
1、下载MySQL
http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.24.tar.gz
2、安装编译工具及库文件(使用CentOS yum命令安装,安装的比较多,方便以后编译安装php、nginx等)
yum install cmake autoconf automake curl curl-devel gcc gcc-c++ gtk+-devel zlib-devel openssl openssl-devel pcre-devel perl kernel-headers compat* cpp glibc libgomp libstdc++-devel keyutils-libs-devel libsepol-devel libselinux-devel krb5-devel libXpm* freetype freetype-devel freetype* fontconfig fontconfig-devel libpng* ncurses* libtool* libxml2 libxml2-devel bison -y
3、安装MySQL
groupadd mysql #添加mysql组
useradd -g mysql mysql #创建用户mysql并加入到mysql组
mkdir -p /opt/mysql55 #创建MySQL安装目录
cd /usr/local/src #进入软件包存放目录
tar zxvf mysql-5.6.24.tar.gz #解压
cd mysql-5.6.24 #进入目录
***********************************补充************************************
4、编译参数简介
cmake \
-DCMAKE_INSTALL_PREFIX=/opt/mysql55 \ #设置安装目录
-DMYSQL_DATADIR=/opt/mysql55/data \ #设置数据库存放目录
-DSYSCONFDIR=/etc \ #设置my.cnf所在目录,默认为安装目录
-DWITH_MYISAM_STORAGE_ENGINE=1 \ #添加MYISAM引擎支持
-DWITH_INNOBASE_STORAGE_ENGINE=1 \ #添加InnoDB引擎支持
-DWITH_MEMORY_STORAGE_ENGINE=1 \ #添加MEMORY支持
-DWITH_PARTITION_STORAGE_ENGINE=1 \ #添加PARTITION支持
-DWITH_READLINE=1 \ #加载readline库
-DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock \ #设置UNIX socket 目录
-DMYSQL_TCP_PORT=3306 \ #设置服务器监听端口,默认3306
-DENABLED_LOCAL_INFILE=1 \ #允许从本地导入数据
-DEXTRA_CHARSETS=all \ #安装所有扩展字符集
-DDEFAULT_CHARSET=utf8 \ #设置默认字符集,默认latin1
-DDEFAULT_COLLATION=utf8_general_ci #设置默认校对规则,默认latin1_general_ci
***************************************************************************
#配置
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -
DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -
DMYSQL_UNIX_ADDR=/var/lib/mysql/mysql.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci
#更多编译的参数可以参考
#http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html
#http://dev.mysql.com/doc/refman/5.6/en/source-configuration-options.html
#编译
make
#安装
make install
cd /opt/mysql55 #进入MySQL安装目录
./scripts/mysql_install_db --user=mysql --basedir=/u01/mysql --datadir=/u01/mysql/data/ #初始化,生成msql系统数据库
cp ./support-files/mysql.server /etc/init.d/mysqld #把Mysql加入系统服务
chmod 755 /etc/init.d/mysqld #增加执行权限
chkconfig mysqld on #加入开机启动
service mysqld start #启动
=======
可能会启动失败:Starting MySQL. ERROR! The server quit without updating PID file (/var/lib/mysql/mysql.top.pid).
1、/u01/mysql 目录的权限 改成mysql
chown -R mysql:mysql /u01/mysql/
2、
rpm -qa | grep -i mysql
rpm -e mysql-libs --nodeps
==========================
#把mysql服务加入系统环境变量:在最后添加下面这一行
vim /etc/profile
export PATH=$PATH:/u01/mysql/bin
mysqladmin -u root -p password "123456" #或者直接修改密码
service mysqld restart #重启
*******************************************************************
MySQL多实例安装
*******************************************************************
#建立data2、data3
[root@www mysql55]# pwd
/opt/mysql55
[root@www mysql55]# ll
total 196
drwxr-xr-x 2 root root 4096 Apr 27 04:48 bin
-rw-r--r-- 1 root root 17987 Mar 26 00:34 COPYING
drwxr-xr-x. 5 mysql mysql 4096 Apr 27 08:55 data
drwxr-xr-x 5 mysql mysql 4096 Apr 27 08:20 data2
drwxr-xr-x 5 mysql mysql 4096 Apr 27 08:25 data3
#初始化,生成mysql系统数据库
./scripts/mysql_install_db --user=mysql --basedir=/opt/mysql55 --datadir=/opt/mysql55/data2
./scripts/mysql_install_db --user=mysql --basedir=/opt/mysql55 --datadir=/opt/mysql55/data3
#修改my.cnf
[mysqld_multi]
mysqld =/opt/mysql55/bin/mysqld_safe
mysqladmin =/opt/mysql55/bin/mysqladmin
user =test
password =test
[mysqld3306]
basedir = /opt/mysql55
datadir = /opt/mysql55/data
port = 3306
pid-file=/tmp/mysql3306.pid
server-id=1
socket = /tmp/mysql3306.sock
[mysqld3307]
basedir = /opt/mysql55
datadir = /opt/mysql55/data2
port = 3307
pid-file=/tmp/mysql3307.pid
server-id=1
socket = /tmp/mysql3307.sock
[mysqld3308]
basedir = /opt/mysql55
datadir = /opt/mysql55/data3
port = 3308
pid-file=/tmp/mysql3308.pid
server-id=1
socket= /tmp/mysql3308.sock
[client]
port =3306
socket =/tmp/mysql.sock
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#启动
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf start 3306 #3307、3308同样
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf statr 3306-3308 #亦可同时启动
#关闭
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 3306
ps -ef|grep 3306 #发现进程还存在
#查看/mysql55/share/mysqld_multi.log 日志
Warning: Using a password on the command line interface can be insecure.
/opt/mysql55/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'test'@'localhost' (using password: YES)'
#由于在my.cnf配置文件设置了test用户、密码
[mysqld_multi]
mysqld =/opt/mysql55/bin/mysqld_safe
mysqladmin =/opt/mysql55/bin/mysqladmin
user =test
password =test
**************
cd /tmp/
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:25 mysql3306.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:28 mysql3307.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:30 mysql3308.sock
srwxrwxrwx 1 mysql mysql 0 Apr 27 08:13 mysql.sock
-rw-------. 1 root root 0 Apr 11 23:18 yum.log
#登陆数据库
[root@www tmp]# mysql -S ./mysql3306.sock
#
mysql> show grants for root@localhost;
+---------------------------------------------------------------------+
| Grants for root@localhost |
+---------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'localhost' WITH GRANT OPTION |
| GRANT PROXY ON ''@'' TO 'root'@'localhost' WITH GRANT OPTION |
+---------------------------------------------------------------------+
2 rows in set (0.00 sec)
#授权并赋予test密码
mysql> grant shutdown on *.* to test@localhost identified by "test" with grant option;
Query OK, 0 rows affected (0.00 sec)
即可成功关闭3306
[root@www mysql55]# ./bin/mysqld_multi --defaults-file=./my.cnf stop 3306
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30164674/viewspace-1605089/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/30164674/viewspace-1605089/