一、MySQL的安装和初始化
mysql安装包下载地址
https://dev.mysql.com/downloads/mysql/
Community_MySQL on Windows_Generally Available(GA)Releases(通用版) 选用
Development Releases(开发版)研究用
2.MySQL 客户端工具
SQLyog Ultimate
HeidiSQL
navicat for mysql
3.压缩包安装方式
从官网上下载mysql-5.6.31-winx64.zip,将其解压,接下来的安装是通过命令来安装MySQL数据库的。
(1)mysql-5.6.31-winx64.zip解压到E:JavaWebDeveloper文件下,打开命令提示符以管理员身份运行,cd到E:JavaWebDevelopermysql-5.6.31-winx64bin下
命令为:cd /d E:JavaWebDevelopermysql-5.6.31-winx64bin
1.png
(2)安装MySQL
mysqld install,运行命令后MySQL安装成功。
2.png
(3)启动MySQL服务。
net start mysql将启动MySQL服务。值得注意的是用命令安装的MySQL在Windows系统下默认服务名为mysql,默认密码为空。
3.png
(4)配置环境变量
1)新建MYSQL_HOME变量,并配置值为:E:JavaWebDevelopermysql-5.6.31-winx64
MYSQL_HOME:E:JavaWebDevelopermysql-5.6.31-winx64
2)编辑path系统变量,将%MYSQL_HOME%bin添加到path变量后。配置path环境变量,也可不新建MYSQL_HOME变量,而是直接将MySQL安装目录下的bin配置到path变量下,
Path:%MYSQL_HOME%bin
4.png
5.png
(5)进入MySQL
mysql -u root -p,密码默认为空。显示“mysql>”表示进入MySQL,可用T-SQL语句对数据库执行各种操作。也可用数据库图形化管理工具对数据库进行管理
6.png
二、net start mysql 服务无法启动
MySQL 5.7.20 net start mysql 服务无法启动-“NET HELPMSG 3534” 的奇怪问题 http://blog.csdn.net/ender__/article/details/53689804
执行mysqld --initialize-insecure出现错误提示
C:WINDOWSsystem32>mysqld --initialize-insecure
mysqld: Can't create directory 'D:Program Files oftmysql-5.7.14-winx64mysql-5.7.14-winx64data' (Errcode: 2 - No such file or directory)
2016-12-16T02:12:53.583901Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2016-12-16T02:12:53.583901Z 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.
2016-12-16T02:12:53.583901Z 0 [Warning] 'NO_AUTO_CREATE_USER' sql mode was not set.
2016-12-16T02:12:53.583901Z 0 [ERROR] Can't find error-message file 'D:Program Files oftmysql-5.7.14-winx64mysql-5.7.14-winx64shareerrmsg.sys'. Check error-message file location and 'lc-messages-dir' configuration directive.
2016-12-16T02:12:53.583901Z 0 [ERROR] Aborting
只好把目录改成反斜杠 在mysql-5.7.14-winx64下面创建my.ini文件,如下
[client]
port=3306
default-character-set=utf8
[mysqld]
port=3306
character_set_server=utf8
basedir=D:/Program Files/soft/mysql-5.7.14-winx64/mysql-5.7.14-winx64
解压目录
datadir=D:/Program Files/soft/mysql-5.7.14-winx64/mysql-5.7.14-winx64/data
解压目录下data目录
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[WinMySQLAdmin]
D:/Program Files/soft/mysql-5.7.14-winx64/mysql-5.7.14-winx64/bin/mysqld.exe
再次执行成功
C:WINDOWSsystem32> mysqld install MySQL --defaults-file="D:Program Filessoftmysql-5.7.14-winx64mysql-5.7.14-winx64my.ini"
Service successfully installed.
C:WINDOWSsystem32>net start mysql
MySQL 服务正在启动 .
MySQL 服务已经启动成功