phpstudy里升级mysql版本到5.7

phpstudy里没有地方可以设置mysql数据库,很多人都疑惑在phpstudy里怎么升级mysql数据库版本,本文就教你如何在phpstudy中升级mysql的版本。

PhpStudy集成环境中的mysql数据库的版本默认是mysql5.5,下面是PhpStudy升级数据库到mysql5.7的方法:

1:备份当前数据库数据,可以导出数据库文件,作为备份。

(导出全部数据库mysqldump -uroot -p --all-databases > sqlfile.sql)

2:备份 PhpStudy 下的 MySQL 文件夹、以防升级失败、还可以使用旧版本的数据库,(重命名PhpStudy下原来的MySQL文件夹即可)

3:下载MySQL5.7、解压、目录修改成MySQL

地址:https://dev.mysql.com/,下载的版本是:mysql-5.7.23-winx64.zip
4:从备份的MySQL目录里拷贝一个my.ini放到D:\phpstudy\MySQL\bin目录里,高版本里my.ini需要放到bin目录里
my.ini内容如下:

[client]

port=3306

[mysql]

default-character-set=utf8

#no-auto-rehash

auto-rehash

[mysqld]

port=3306

basedir="D:/software/gongju/PhpStudy/PHPTutorial/MySQL/" #根据实际情况修改

datadir="D:/software/gongju/PhpStudy/PHPTutorial/MySQL/data" #根据实际情况修改

character-set-server=utf8

default-storage-engine=INNODB

#支持 INNODB 引擎模式。修改为 default-storage-engine=INNODB 即可。

#如果 INNODB 模式如果不能启动,删除data目录下ib开头的日志文件重新启动。

sql_mode=ONLY_FULL_GROUP_BY,STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

query_cache_size=0

tmp_table_size=32M

thread_cache_size=8

myisam_max_sort_file_size=64G

myisam_sort_buffer_size=35M

key_buffer_size=25M

read_buffer_size=64K

read_rnd_buffer_size=256K

sort_buffer_size=256K

explicit_defaults_for_timestamp=true

 

innodb_flush_log_at_trx_commit=1

innodb_log_buffer_size=1M

innodb_buffer_pool_size=47M

innodb_log_file_size=24M

secure-file-priv = NULL

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_thread_concurrency=8

innodb_file_per_table = 1

skip-grant-tables = 1

# 跳过验证,重置密码后注释

5:进入这个目录:D:/phpstudy/MySQL/bin

按住shift键,鼠标右键,在此打开命令行
初始化mysql
mysqld --initialize-insecure --user=mysql
安装mysql5.7服务
mysqld –install
启动mysql
net start mysql
关闭mysql
net stop mysql

5:登入mysql并修改密码
mysql -u root –p

直接回车,因为配置文件里配置了不进行登录验证
进入mysql后执行:ALTER USER USER() IDENTIFIED BY 'root';

#修改root密码
6:至此, phpstudy的mysql就升级完了

7:把配置文件里的skip-grant-tables = 1去掉或者注释掉再重启mysql

8:再次通过命令行的方式进入数据库,执行source sqlfile.sql; 恢复之前备份的数据库

posted @ 2019-02-14 23:45  谁懂烟花忧伤  阅读(591)  评论(0编辑  收藏  举报