Home > Database > Mysql Tutorial > 实战:mysql版本升级_MySQL

实战:mysql版本升级_MySQL

WBOY
Release: 2016-06-01 13:02:38
Original
943 people have browsed it

 

/*****************************************************
mysql 5.6.19 升级到5.6.21

*****************************************************/
升级前做好备份是必须的!

----1.查看现有版本mysql的数据目录位置

show variables like '%datadir%';

/usr/local/mysql01/data/ 

---2.安装新版本MySQL

2.1.安装编译代码需要的包

yum -y install  gcc gcc-c++  autoconf automake zlib*  libxml* \
ncurses-devel libtool-ltdl-devel* make cmake bison bison-devel libaio

 

2.2.为mysql新建组和用户

#groupadd mysql

#useradd -g mysql  mysql 

2.3.设置用户的系统资源限制

#vi /etc/security/limits.conf

mysql            soft    nproc   2047
mysql            hard    nproc   16384
mysql            soft    nofile  1024
mysql            hard    nofile  65536

2.4.编译安装新版本mysql

tar xvf mysql-5.6.21.tar.gz

cd mysql-5.6.21

编译安装到新位置

cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql02 \
-DMYSQL_DATADIR=/usr/local/mysql02/data \  
-DSYSCONFDIR=/etc \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_MEMORY_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql02/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DEXTRA_CHARSETS=all \
-DDEFAULT_COLLATION=utf8_general_ci

make 

make install

2.5 停止老版本mysql

service mysqld stop

----3.配置MySQL

3.1.修改/usr/local/mysql权限

#mkdir -p /usr/local/mysql02

3.2.新建数据文件、临时文件

mkdir /usr/local/mysql02/{innodb_data,data,tmp}  -p

mkdir /usr/local/mysql02/mysql_logs/{binary_log,innodb_log,query_log,slow_query_log,error_log}  -p

3.3.修改权限

cd /usr/local/mysql02
chown -R mysql .
chgrp -R mysql .

3.4.修改参数

#vi /etc/my.cnf   

basedir = /usr/local/mysql#数据库安装目录指定到新版本的安装目录 
datadir = /var/lib/mysql #原数据库数据目录保持原来的目录即可 
skip-grant-tables  #由于升级需要,跳过权限验证 
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 中 
#去掉STRICT_TRANS_TABLES,禁用数据严格模式 
#只需要修改这些,其它的一般不需修改,如果需要将日志之类的转移到新目录,则按需修改

3.5.覆盖启动文件
#cp /usr/local/mysql02/support-files/mysql.server   /etc/init.d/mysqld 

3.6.执行表权限升级 

#service mysqld start #重启新版本MySQL 

#/usr/local/mysql02/bin/mysql_upgrade  #执行表权限升级 

3.7.检查所有数据库
#/usr/local/mysql02/bin/mysqlcheck --all-databases -uroot -p123456   

3.8.重新启动mysql

#vi /etc/my.cnf  
去掉skip-grant-tables  

#service mysqld restart #数据库升级成功 
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template