你安装的mysql位置不是c盘的话应该出现此问题。
1.打开bin下的mysql_config.pl文件,查找以下几行,把目录改成你安装mysql的目录即可。
my $ldata = 'C:/Program Files/MySQL/MySQL Server 5.7/data'; my $execdir = 'C:/Program Files/MySQL/bin'; my $bindir = 'C:/Program Files/MySQL/bin'; my $pkglibdir = fix_path('C:/Program Files/MySQL/lib',"libmysql/relwithdebinfo", "libmysql/release","libmysql/debug","lib/mysql","lib"); my $pkgincludedir = fix_path('C:/Program Files/MySQL/include', "include/mysql", "include");
我是安装在D盘所以改成了如一下几行:
my $ldata = 'D:/Program Files/MySQL/MySQL Server 5.7/data'; my $execdir = 'D:/Program Files/MySQL/bin'; my $bindir = 'D:/Program Files/MySQL/bin'; my $pkglibdir = fix_path('D:/Program Files/MySQL/lib',"libmysql/relwithdebinfo", "libmysql/release","libmysql/debug","lib/mysql","lib"); my $pkgincludedir = fix_path('D:/Program Files/MySQL/include', "include/mysql", "include");
2.以管理员身份运行cmd,输入:mysqld -install(如果不用管理员身份运行,将会因为权限不够而出现错误:Install/Remove of the Service Denied!)
3.运行mysqld --initialize(标题问题所在,若没有init则不存在data目录,自然无法启动成功)
4.安装成功后就要启动服务了,继续在cmd中输入:net start mysql,服务启动成功!
5.服务启动成功之后,就可以登录了
在mysql目录下搜索*.err,以文本形式打开才能看到如下内容:
016-02-25T15:09:43.033062Z 1 [Note] A temporary password is generated for root@localhost: >mso<k70mrWe
红色字母即为第一次的登陆密码,记得加双引号。
输入mysql -u root -p回撤输入密码即可登录
6.修改密码
格式:mysql> set password for 用户名@localhost = password('新密码');