1.mysql数据库安装:
下载:https://dev.mysql.com/downloads/installer/
本人电脑下载的是mysql-5.7.26-winx64.zip
下载完成之后解压到安装目录:C:\Program Files (x86)\mysql\mysql-5.7.26-winx64
解压完成之后再解压的这个目录中新建一个my.ini的文件内容为:
[mysql]
default-character-set=utf8
[mysqld]
port=3306
explicit_defaults_for_timestamp=true
basedir=C:\Program Files (x86)\mysql\mysql-5.7.26-winx64
datadir=C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\mysql
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
如图:
然后打开cmd窗口执行mysqld --initialize-insecure --user=mysql
再执行net start mysql
到此数据库安装启动完成
2.总结:
1+.
刚开始自己解压完成之后什么都没有配置直接启动mysql出现如下报错:
C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\bin>net start mysql
MySQL 服务正在启动 .
MySQL 服务无法启动。
服务没有报告任何错误。
第一次遇到也不知道是什么问题:
查资料解决问题发现自己什么都没有配置 ,启动时失败的
2+添加了配置文件
C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\bin>mysqld --initialize-insecure --user=mysql
mysqld: Character set 'utf-8' is not a compiled character set and is not specified in the 'C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\share\charsets\Index.xml' file
2019-06-19T07:39:02.001634Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-19T07:39:02.004762Z 0 [ERROR] Aborting
解决:之前第一次自己写的配置文件写的utf-8时这个,最后修改为utf8
C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\bin>mysqld --initialize-insecure --user=mysql
2019-06-19T07:41:20.760567Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-06-19T07:41:20.761171Z 0 [ERROR] Aborting
解决:不用解决:这个是已经给数据库做过初始化了(不影响使用)
C:\Program Files (x86)\mysql\mysql-5.7.26-winx64\bin>mysqld --initialize-insecure --user=mysql
2019-06-19T07:39:55.131303Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2019-06-19T07:39:55.133401Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2019-06-19T07:39:55.133845Z 0 [ERROR] Aborting
解决:给my.ini添加:
explicit_defaults_for_timestamp=true