原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的升级操作及数据转移