Windows下安装MySQL5.7
在MySQL中建表的时候遇到一个错误:Incorrect table definition; there can be only one TIMESTAMP column with CURRENT_TIMESTAMP in DEFAULT or ON UPDATE clause
查了一下,这是因为表中定义了多个时间戳字段,并且设置了值默认为当前时间戳,所以会报这个错。
解决方法很简单:升级MySQL到5.7版本以上。
下面,开始升级MySQL到5.7版本,小版本根据个人爱好自行选择,我选择的版本是5.7.20。先停掉原来的MySQL服务,打开任务管理器,找到mysqld进程,选择结束进程。
备份原来的数据,找到MySQL相应的版本目录下面,有data目录,将此目录备份。
运行MySQL的卸载程序,可以使用电脑管家来进行卸载,或者在控制面板里面卸载。
进入官网下载MySQL5.7.20的安装程序,地址:https://downloads.mysql.com/archives/installer/,进行下载页面后,就可以选择对应的版本下载了。
安装过程不详细说了,不会的自行上网查询。
在安装过程中可能会遇到的一个错误(我自己就遇到了):1: Action 14:19:48: INSTALL.
1: 1: MySQL Server 5.7 2: {81B27388-3733-4B65-8D84-AD9C9113B498}
1: Action 14:19:48: FindRelatedProducts. Searching for related applications
1: Action 14:19:48: AppSearch. Searching for installed applications
1: Action 14:19:48: LaunchConditions. Evaluating launch conditions
1: This application requires Visual Studio 2013 Redistributable. Please install the Redistributable then run this installer again.
1: 1: MySQL Server 5.7 2: {81B27388-3733-4B65-8D84-AD9C9113B498} 3: 3
1: The action 'Install' for product 'MySQL Server 5.7.20' failed.
大致原因是自动安装的Visual Studio 2013 Redistributable包有问题,解决方法就是手动从微软官网下载一个安装,下载地址:https://www.microsoft.com/zh-CN/download/details.aspx?id=40784,点击下载按钮,将vcredist_x64和vcredist_86都下载下来,下载完成后,先安装vcredist_x64,然后再尝试安装MySQL,如果还是失败,则安装vcredist_86,然后再次安装MySQL,到此,问题应该就解决了。
剩下的,就是MySQL的配置问题了,这些网上很多配置教程,需要的自行上网搜索,就不在此详细赘述了。