Thursday, 17 September 2015

Upgrade MySQL 5.6 to 5.7



1. Create demo DB on MySQL 5.6



2. Stop MySQL5.6 Service
 [root@Master ~]# service mysql stop
Shutting down MySQL.. SUCCESS!
[root@Master local]# ls -lah
total 880M
drwxr-xr-x. 13 mysql mysql 4.0K Sep 17 14:42 mysql
-rw-r--r--.  1 root  root  291M Apr  8  2013 mysql-5.6.11-linux-glibc2.5-x86_64.tar.gz
-rw-r--r--.  1 root  root  588M Sep 17 12:35 mysql-5.7.8-rc-linux-glibc2.5-x86_64.tar.gz
 3. Rename the old mysql folder as mysql_56
 [root@Master local]# mv mysql mysql_56
 4. Install MySQL 5.7 on the same Server
[root@Master local]# tar -zxvf mysql-5.7.8-rc-linux-glibc2.5-x86_64.tar.gz
mysql-5.7.8-rc-linux-glibc2.5-x86_64/
mysql-5.7.8-rc-linux-glibc2.5-x86_64/bin/
mysql-5.7.8-rc-linux-glibc2.5-x86_64/bin/mysqladmin
mysql-5.7.8-rc-linux-glibc2.5-x86_64/bin/mysql_config_editor
mysql-5.7.8-rc-linux-glibc2.5-x86_64/bin/myisam_ftdump
………………………………………..
[root@Master local]# ls -lah
total 880M
drwxr-xr-x. 13 mysql mysql 4.0K Sep 17 14:42 mysql_56
-rw-r--r--.  1 root  root  291M Apr  8  2013 mysql-5.6.11-linux-glibc2.5-x86_64.tar.gz
drwxr-xr-x.  9  7161 wheel 4.0K Jul 20 20:54 mysql-5.7.8-rc-linux-glibc2.5-x86_64
-rw-r--r--.  1 root  root  588M Sep 17 12:35 mysql-5.7.8-rc-linux-glibc2.5-x86_64.tar.gz
 [root@Master local]# cd mysql
[root@Master mysql]# ls -lah bin
total 1.3G
drwxr-xr-x. 2 7161 wheel 4.0K Jul 20 20:54 .
drwxr-xr-x. 9 7161 wheel 4.0K Jul 20 20:54 ..
-rwxr-xr-x. 1 7161 wheel 6.1M Jul 20 20:42 innochecksum
-rwxr-xr-x. 1 7161 wheel 8.6M Jul 20 20:42 myisamchk
-rwxr-xr-x. 1 7161 wheel  11M Jul 20 20:42 mysql_install_db
-
……..
-rwxr-xr-x. 1 7161 wheel 5.4M Jul 20 20:41 resolveip
-rwxr-xr-x. 1 7161 wheel 5.4M Jul 20 20:41 resolve_stack_dump
[root@Master mysql]# bin/mysql_install_db --user=mysql
2015-09-17 15:24:30 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-09-17 15:24:30 [ERROR]   The data directory needs to be specified.
[root@Master mysql]# chown -R mysql .
[root@Master mysql]# chgrp -R mysql .
[root@Master mysql]# bin/mysql_install_db --user=mysql
2015-09-17 15:51:26 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-09-17 15:51:26 [ERROR]   The data directory needs to be specified.
[root@Master mysql]# bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
2015-09-17 15:57:35 [WARNING] mysql_install_db is deprecated. Please consider switching to mysqld --initialize
2015-09-17 15:57:58 [WARNING] The bootstrap log isn't empty:
2015-09-17 15:57:58 [WARNING] mysqld:
OpenSSL 1.0.1e-fips 11 Feb 2013
server-cert.pem: OK
client-cert.pem: OK
[root@Master mysql]# bin/mysqld_safe --user=mysql &
[1] 46040
[root@Master mysql]# 150917 16:09:15 mysqld_safe Logging to '/usr/local/mysql/data/Master.err'.
150917 16:09:16 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
#MySQL 5.7 will auto generate a temporary password and stored in mysql_secret
[root@Master mysql]# find / -name '*mysql_secret'
/root/.mysql_secret
[root@Master mysql]# cat /root/.mysql_secret
# Password set for user 'root@localhost' at 2015-09-17 15:57:35
McTVpdK+Ugwd
[root@Master mysql]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 317
Server version: 5.7.8-rc-log
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql> alter user user() identified by '123123';
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.04 sec)






5. Point the mysql57 datadir to old data folder mysql_56
 



6. Start mysql 5.7 service
[root@Master local]# service mysql start
Starting MySQL.... SUCCESS!

 


7. Run mysql_upgrade















No comments:

Post a Comment