我本地的phpstudy是2018版本的的mysql版本是mysql5.51的,现在从其他地方导入mysql5.7以上的sql会出现
错误代码: 1293
Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause )
有些导入不进去,因此解决方案把phpstudy默认的MySQL5.51版本升级为mysql5.7.24,首先去mysql官网下载https://dev.mysql.com/downloads/file/?id=481160我下载的版本是:mysql-5.7.24-winx64.zip
一:把原来MySQL备份为MySQL_back
二:把mysql-5.7.24-winx64.zip解压到D:\phpstudy\PHPTutorial并改名为MySQL
三:从MySQL_back里拷贝一个my.ini放到D:\phpstudy\PHPTutorial\MySQL\bin目录里,高版本里my.ini需要放到bin目录里
复制下方代码直接覆盖my.ini,其中只需注意
basedir="D:/phpstudy/PHPTutorial/MySQL/"
datadir="D:/phpstudy/PHPTutorial/MySQL/data/"
换成你自己的实际目录位置
[client]
port=3306
[mysql]
default-character-set=utf8
[mysqld]
port=3306
basedir="D:/phpstudy/PHPTutorial/MySQL/"
datadir="D:/phpstudy/PHPTutorial/MySQL/data/"
character-set-server=utf8
default-storage-engine=INNODB
#支持 INNODB 引擎模式。修改为 default-storage-engine=INNODB 即可。
#如果 INNODB 模式如果不能启动,删除data目录下ib开头的日志文件重新启动。
max_connections=512
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
innodb_additional_mem_pool_size=2M
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=47M
innodb_log_file_size=24M
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 #跳过权限验证
log-error = D:/phpstudy/PHPTutorial/MySQL/data/error.log
四:然后已管理员身份运行cmd
先从c盘切换到 d:盘
进入这个目录:cd phpstudy/PHPTutorial/MySQL/bin
初始化mysql
mysqld --initialize-insecure --user=mysql
(这步可能会出现提示由于找不到MSVCR120.dll和MSVCP120.dll,无法继续执行代码 是因为你win10系统缺乏一些库文件直接下载安装一下链接http://www.pc6.com/softview/SoftView_104246.html就好了)
安装mysql5.7服务
mysqld –install
启动mysql
net start mysql
五:登入mysql并修改密码
mysql -u root -p
直接回车,因为配置文件里配置了不进行登录验证 (skip-grant-tables = 1 #跳过权限验证)
进入mysql后执行:ALTER USER USER() IDENTIFIED BY 'root';修改root密码
六:问题产生:
安装好phpstudy后,升级了MySQL后,通过phpstudy启动,Apache可以启动,Mysql无法启动。
解决方法:
之前已经装过Mysql,要把系统服务里面的MySQL删除,留下MySQLa服务。
在cmd命令行下输入:sc delete mysql 即可删除。
OK