win10 安装MySQL过程和遇到的坑

环境:win10系统,MySQL5.7.18 “mysql-5.7.18-winx64.msi”

首先是要运行mysql-5.7.18-winx64.msi,选择安装在C盘(可自定义安装)

第一步

打开命令控制台Cmd ,并进入MySQL安装目录bin目录中

C:\Users\Administrator.JX-201906191059>cd "C:\Program Files\MySQL\MySQL Server 5.7\bin"

第二步:安装MySQL服务(不进行这步,MySQL不会在服务中)

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --install

Service successfully installed.

第三步:初始化数据库,在这之前需要先创建my.ini配置文件,放在MySQL安装目录

#### my.ini文件 start #### 更多配置请百度!!!
[client]

port = 3306

default-character-set=utf8  

[mysqld]

skip-grant-tables

port = 3306

character_set_server=utf8

#安装目录

basedir=C:\Program Files\MySQL\MySQL Server 5.7

#data目录与安装目录分离

datadir=F:\MySQL\data

#红色参数解决下面  #错误一

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

#以下配置,详情可以百度。

key_buffer_size = 16M

max_allowed_packet = 1M

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

explicit_defaults_for_timestamp=true 

#错误日志文件

log-error=F:/MySQL/log/mysql-err.log

#### my.ini文件 END ####

#错误一

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize

2019-06-24T02:37:29.141533Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).

2019-06-24T02:37:29.142503Z 0 [Warning] 'NO_ZERO_DATE', 'NO_ZERO_IN_DATE' and 'ERROR_FOR_DIVISION_BY_ZERO' sql modes should be used with strict mode. They will be merged with strict mode in a future release.

2019-06-24T02:37:29.142503Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.

2019-06-24T02:37:29.142503Z 0 [ERROR] Can't find error-message file 'D:\Program Files\MySQL\MySQL Server 5.7\share\errmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.

2019-06-24T02:37:29.146523Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.

2019-06-24T02:37:29.146523Z 0 [ERROR] Aborting

#错误二,因为data目录有文件(之前操作生成的,删除即可)

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize

2019-06-24T02:41:50.026106Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.

2019-06-24T02:41:50.027134Z 0 [ERROR] Aborting

 #初始化数据库

C:\Program Files\MySQL\MySQL Server 5.7\bin>mysqld --initialize

启动MySQL:

恭喜 MySQL服务可以使用了

客户端工具推荐:

好用才是王道……

祝你在编码路上,少走弯路……加油!

转载于:https://www.cnblogs.com/cyun/p/11076178.html

猜你喜欢

转载自blog.csdn.net/weixin_34410662/article/details/93927592
今日推荐