1.安装依赖:
yum -y install gcc* autoconf automake zlib* fiex* libxml* ncurses* libmcrypt* libtool-ltdl-devel* make cmake
2.解压:
tar -zxvf mysql-5.6.22.tar.gz
3.路径:
cd mysql-5.6.22 ;
cmake -DCMAKE_INSTALL_PREFIX=/usr/
local
/mysql
4.编译安装:
make && make install
5.设置目录权限:
chown -R mysql:mysql /usr/
local
/mysql
6.
mkdir -p /data01/mysql/ (mysql 数据文件)
chown -R mysql:mysql /data01/mysql/
mkdir -p /var/log/mysql/ (mysql 日志文件)
chown -R mysql:mysql /var/log/mysql
mkdir -p /var/run/mysqld (mysql 运行文件)
chown -R mysql:mysql /var/run/mysqld
mkdir -p /data01/mysqllog/binlog/ (mysql 二进制日志文件)
chown -R mysql:mysql /data01/mysqllog
7.
创建用户安装mysql:
groupadd mysql
useradd -m -g mysql -s /sbin/nologin mysql
8.安装mysql:
/usr/
local
/mysql/scripts/mysql_install_db
--user=mysql --basedir=/usr/local/mysql --datadir=/data01/mysql/ --安装db
看到两个 OK 就说明安装成功
9.
设置开机自启及启动服务:
cp /usr/
local
/mysql/support-files/mysql.server /etc/init.d/mysql
chkconfig
--add mysql && chkconfig mysql on
10.设置 mysql 配置文件:
cp /usr/
local
/mysql/my
.cnf /etc/my.cnf
将 my.cnf 中的内容替换
11.配置 PATH 环境变量:
PATH=$PATH:/usr/local/mysql/bin/
echo "export
PATH=$PATH:/usr/local/mysql/bin/
" >> /root/.bash_profile
12.设置 mysql.sock 软连接:
ln -s /data01/mysql/mysql.sock /tmp/mysql.sock
13:启动 mysql:
/etc/init.d/mysql start
14.mysql 系统初始化:
/usr/local/mysql/bin/mysql_secure_installation
设置root 密码:
mysqladmin -uroot
password
'1234567'
15. mysql 数据导出,导入
导出:mysqldump --all-databases -u root -p > /root/slave.sql
导入:> source /root/slave.sql
备注:
1./etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data01/mysql
socket=/data01/mysql/mysql.sock
user=mysql
slow_query_log=ON
long_query_time=2
server-id=135
log-bin=/data01/mysqllog/binlog/mysql-bin
binlog_format=MIXED
max_binlog_size = 512M
binlog_cache_size = 128K
character-set-server=utf8
default-storage-engine=INNODB
innodb_file_per_table=1
sync_binlog=2
symbolic-links=0
max_connections=1024
[mysqld_safe]
log-error=/var/log/mysql/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES