背景

由于phpstudy2016集成环境默认的mysql版本是5.5,所以没法使用mysql5.6新添加的功能optimizer_trace,因此有必要把mysql版本升级下

一、 当前环境

  • win10
  • phpstudy2016
  • mysql5.5

二、升级

1、备份
#备份数据
$ ./mysqldump.exe -uroot -proot --all-databases --lock-all-tables > g:/backup.sql
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.

#备份文件夹
2、下载

https://dev.mysql.com/downloads/file/?id=480303

3、配置
  • 将下载的mysql解压到phpstudy目录
  • 将my.default.ini重命名为my.ini,然后在配置文件添加
basedir="D:/phpStudy/MySQL/"
datadir="D:/phpStudy/MySQL/data/"
  • 在bin目录下用管理员权限运行cmd
#初始化数据库
D:\phpStudy\MySQL\bin>mysqld.exe --initialize
2018-11-06 14:21:09 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-11-06 14:21:09 0 [Note] --secure-file-priv is set to NULL. Operations related to importing and exporting data are disabled
2018-11-06 14:21:09 0 [Note] mysqld.exe (mysqld 5.6.42) starting as process 9392 ...

#安装服务
D:\phpStudy\MySQL\bin>mysqld.exe -install
Service successfully installed.

#启动服务
D:\phpStudy\MySQL\bin>net start MySQL
MySQL 服务正在启动 .
MySQL 服务已经启动成功。
  • 这时已经可以登入mysql了,默认是没有密码的,如果需要修改密码可以在配置中先添加skip-grant-tables参数再进入mysql修改密码
D:\phpStudy\MySQL\bin>mysql -uroot -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.42 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, 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.
  • 将备份的数据恢复
source g:/backup.sql

发表评论

电子邮件地址不会被公开。 必填项已用*标注