Mysql升级到最新版本mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

1.从官网下载最新版本的 mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz

2.解压安装包并将解压包里的内容拷贝到mysql的安装目录/home/mysql

[mysql@i-2-1369-VM ~]$ tar -zxvf /tmp/mysql-5.7.16-linux-glibc2.5-x86_64.tar.gz
[mysql@i-2-1369-VM ~]$ mv mysql-5.7.16-linux-glibc2.5-x86_64 ./mysql5716

3.初始化mysql数据库

[mysql@i-2-1369-VM ~]$ cd mysql5716/
[mysql@i-2-1369-VM mysql5716]$ ./bin/mysqld --user=mysql --basedir=/home/mysql/mysql5716 --datadir=/home/mysql/mysql5716/data --initialize
2016-10-21T00:44:18.158027Z 0 [Warning] Changed limits: max_open_files: 1024 (requested 5000)
2016-10-21T00:44:18.158199Z 0 [Warning] Changed limits: table_open_cache: 431 (requested 2000)
2016-10-21T00:44:18.158553Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-10-21T00:44:18.778413Z 0 [Warning] InnoDB: New log files created, LSN=45790
2016-10-21T00:44:18.873774Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2016-10-21T00:44:18.939175Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 800f6a9b-9727-11e6-a
d36-06028e00554a.2016-10-21T00:44:18.951243Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2016-10-21T00:44:18.952610Z 1 [Note] A temporary password is generated for root@localhost: gK/juq6isipf

牢记上面的随机密码, 如上“, 下面我们修改密码时需要用到。

4.修改配置文件

[mysql@i-2-1369-VM mysql5716]$ vi ./support-files/mysql.server
----------
basedir=/home/mysql/mysql5716
datadir=/home/mysql/mysql5716/data
----------
[mysql@i-2-1369-VM mysql5716]$ vi ./support-files/my-default.cnf
----------
[mysqld]

basedir = /home/mysql
datadir = /home/mysql/data

character_set_server=utf8
init_connect='SET NAMES utf8'


[client]
default-character-set=utf8
----------

5.备份原来数据库并停掉原来的服务

[mysql@i-2-1369-VM ~]$ ./bin/mysqldump -uroot -p basic > basicbak.sql
[mysql@i-2-1369-VM ~]$ ./support-files/mysql.server stop

6.启动新版本mysql,更改初始密码

[mysql@i-2-1369-VM mysql5716]$ ./bin/mysqladmin -u root -p password
Enter password: 
New password: 
Confirm new password: 
[mysql@i-2-1369-VM mysql5716]$ ./support-files/mysql.server start

7.创建库,并导入数据

[mysql@i-2-1369-VM mysql5716]$ ./bin/mysql -uroot -p

mysql> CREATE DATABASE `basic` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
Query OK, 1 row affected (0.00 sec)

[mysql@i-2-1369-VM mysql5716]$ ./bin/mysql -uroot -p basic < ../basicbak.sql 

至此,mysql已经升级完成


另外,目前我还没有研究出mysql_5.7.15怎么备份和导入用户权限,以后有机会在补充用户权限的导入导出

你可能感兴趣的:(Mysql)