MySql教程

mysql 5.6升级至mysql 5.7及数据转移过程记录

本文主要是介绍mysql 5.6升级至mysql 5.7及数据转移过程记录,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

 

原mysql安装版本:5.6.28,安装使用包:mysql-5.6.28-linux-glibc2.5-x86_64.tar.gz

升级后mysql版本:5.7.22,安装使用包:mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz   停服务,备走数据文件
/etc/init.d/mysqld stop
mv /opt/mysql /tmp/mysql.bak

 

快速部署mysql 5.7

useradd -s /sbin/nologin mysql
tar -xf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz
mv mysql-5.7.22-linux-glibc2.12-x86_64 /opt/mysql
chown -R mysql.mysql mysql

#初始化
/opt/mysql/bin/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/opt/mysql/ --datadir=/opt/mysql/data --user=mysql

#还原备份数据库
cp -rp /tmp/mysql.bak/data/dannydb /opt/mysql/data
chown -R mysql.mysql /opt/mysql/

#不想去找初始随机密码,直接免密登录
vim /etc/my.cnf
[mysqld]
skip-grant-tables

#重启生效
/etc/init.d/mysqld restart

#登录操作
mysql> grant all on *.* to 'root'@'%' identified by  'Vdanny@123#sHG';
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

#按错误提示更新密码
mysql> update mysql.user set authentication_string=password('Vdanny@123#sHG') where user="root" and host="localhost";
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

#退出注销免密登录,重启服务
vim /etc/my.cnf
[mysqld]
#skip-grant-tables
/etc/init.d/mysqld restart

#重新用密码登录
mysql -uroot -p

#创建用户并赋权
mysql> grant all on *.* to 'root'@'%' identified by  'Vdanny@123#sHG';
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

#按错误提示更新密码
ALTER USER  'root'@'localhost' IDENTIFIED BY Vdanny@123#sHG';
flush privileges

#再次赋权
grant all on *.* to 'root'@'%' identified by  'Vdanny@123#sHG';
flush privileges

#完成,登录测试还原数据是否完整
mysql -uroot -p -h 192.168.1.10

 

至此,完成快速mysql 5.6至mysql 5.7的升级操作及数据转移
这篇关于mysql 5.6升级至mysql 5.7及数据转移过程记录的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!