mysql5.7.9 windows平台下zip包解压安装

有段时间没有在本地做开发了,今天打算在本地搭建一个开发环境。
先去下载了mysql 5.7.9 win64 zip包,解压到C:\mysql
以管理员的身份运行cmd,切换到mysql解压目录的bin目录下
cd /d C:\mysql\bin
提示如下错误
mysqld: Can't change dir to 'C:\mysql\data\' (Errcode: 2 - No such file or directory)
2015-12-07T12:36:23.809149Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-07T12:36:23.809149Z 0 [Warning] Insecure configuration for --secure-file-priv: Current value does not restrict location of generated files. Consider setting it to a valid, non-empty path.
2015-12-07T12:36:23.809149Z 0 [ERROR] Cannot open Windows EventLog; check privileges, or start server with --log_syslog=0
2015-12-07T12:36:23.809149Z 0 [Note] mysqld (mysqld 5.7.9) starting as process 38972 ...
2015-12-07T12:36:23.824775Z 0 [Warning] Can't create test file C:\mysql\data\jackslap.lower-test
2015-12-07T12:36:23.824775Z 0 [Warning] Can't create test file C:\mysql\data\jackslap.lower-test
2015-12-07T12:36:23.824775Z 0 [ERROR] failed to set datadir to C:\mysql\data\
2015-12-07T12:36:23.824775Z 0 [ERROR] Aborting
根据提示,mysql的默认data目录是在mysql的安装目录下,再次启动mysqld
c:\mysql\bin>mysqld
启动客户端连接
c:\mysql\bin >mysql -uroot -p
竟然提示错误,服务无法连接,于是先查看下端口的监听情况
c:\mysql\bin>netstat -aon | findstr 3306
输出记录为空,看来mysqld确实没有启动成功啊,添加启动参数 --console
c:\mysql\bin>mysqld --console
输出的log中Error级别
2015-12-07T13:31:22.385221Z 0 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
2015-12-07T13:31:22.400840Z 0 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.user' doesn't exist
2015-12-07T13:31:22.416465Z 0 [ERROR] Aborting
发现都是mysql库中的表找不到,使用过mysql的都知道mysql有一个也叫mysql的db,存放的的是mysql中的一些元信息。
但是记忆中,之前的版本都是带有mysql库的。查看下是否有其他的启动参数
c:\mysql\bin>mysqld --verbose --help > 1.txt
因为加了--verbose,信息有点多,重定向到文件中
在1.txt中发现启动初始化参数
  --initialize        Create the default database and exit. Create a super user
                      with a random expired password and store it into the log.
再次使用--initialize 参数启动mysqld
c:\mysql\bin>mysqld --initialize --console
提示如下错误信息,data 目录下有其他文件,无法完成初始化
2015-12-07T13:40:04.331034Z 0 [ERROR] --initialize specified but the data directory has files in it. Aborting.
2015-12-07T13:40:04.331034Z 0 [ERROR] Aborting
情况data目录,再次启动
c:\mysql\bin>mysqld --initialize --console
c:\mysql\bin>mysqld
在输出的日志最后一行,提示为本机的mysql的root用户生成了一个临时密码
2015-12-07T13:42:36.784829Z 1 [Note] A temporary password is generated for root@localhost : U?0d&yztGvI.
使用临时密码登陆后,再修改root的密码
c:\mysql\bin>mysql -uroot -p
输入上面生成的临时密码,更新root密码
mysql>set password for 'root'@'localhost'=password('123456');
提示成功后,推出mysql客户端,重新使用新的密码登陆,这里的123456根据个人需要修改成自己的。
为了方便,可以把mysql安装为windows的服务
c:\mysql\bin>mysqld --install mysql
上面的命令将mysql安装成名为mysql的服务,使用net start mysql启动改服务
c:\mysql\bin>net start mysql

你可能感兴趣的:(mysql,安装,mysqld,服务)