window安装mysql5.7.11

1、到mysql官网(http://dev.mysql.com/downloads/mysql/)下载压缩包,我的是win7 64位的,根据自己的系统进行下载

window安装mysql5.7.11

2、解压到自己的目录,我的是 E:\software\dataBase\mysql-5.7.11-winx64,并修改其目录下的my-default.ini文件

 

 # For advice on how to change settings please see

 # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the

 # *** default location during install, and will be replaced if you

 # *** upgrade to a newer version of MySQL.


 [client]
 default-character-set=utf8
 
 [mysqld]
 port=3306
 basedir =E:\software\dataBase\mysql-5.7.11-winx64
 datadir =E:\software\dataBase\mysql-5.7.11-winx64\data
 tmpdir =E:\software\dataBase\mysql-5.7.11-winx64\data
 socket =E:\software\dataBase\mysql-5.7.11-winx64\data\mysql.sock
 log-error =E:\software\dataBase\mysql-5.7.11-winx64\data\mysql_error.log
 
 #server_id = 2
 #skip-locking

 max_connections=100
 table_open_cache=256
 query_cache_size=1M
 

 tmp_table_size=32M
 thread_cache_size=8


 innodb_data_home_dir=E:\software\dataBase\mysql-5.7.11-winx64\data
 innodb_flush_log_at_trx_commit =1
 innodb_log_buffer_size=128M
 innodb_buffer_pool_size=128M
 innodb_log_file_size=10M
 innodb_thread_concurrency=16
 innodb-autoextend-increment=1000
 join_buffer_size = 128M
 sort_buffer_size = 32M
 read_rnd_buffer_size = 32M
 max_allowed_packet = 32M
 explicit_defaults_for_timestamp=true
 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
 #sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

 

3、以管理员身份运行cmd  ,cd 到 E:\software\dataBase\mysql-5.7.11-winx64\bin目录

4、执行 mysqld.exe --initialize --user=mysql 命令

5、执行 mysqld.exe -install  安装服务命令

6、执行 net start mysql 检查是否安装成功

window安装mysql5.7.11

7、执行mysql mysql -uroot -p 进入mysql

8、输入密码,第一次密码可以从下面文件中找到

window安装mysql5.7.11

window安装mysql5.7.11

输入密码,进入如下界面

window安装mysql5.7.11

9、执行  set password = password('mysql');  命令 重新设置密码

window安装mysql5.7.11

 

update mysql.user set authentication_string=password('123qwe') where user='root';

 

安装MySQL出现 Install/Remove of the Service Denied!

win10下 安装 MySQL 命令下进入bin目录  执行 mysqld.exe  -install 时,

却出现 Install/Remove  of   the  Service   Denied!

把bin目录加入到系统环境变量也不行。

安装MySQL出现 Install/Remove of the Service Denied!

解决方案:

以管理员身份运行 cmd 即可

再次输入 mysqld.exe    -install  显示 Service successfully installed
安装MySQL出现 Install/Remove of the Service Denied!

然后 net start mysql 服务就添加到系统服务中了。

安装MySQL出现 Install/Remove of the Service Denied!

输入 net start mysql ,可以看到 MySQL 启动
安装MySQL出现 Install/Remove of the Service Denied!

 

问题汇总:在之前的开启服务过程中失败了很多次,也是从网上各种找问题原因,下面我就介绍一下我遇到的问题,仅供大家参考,如果还有其它问题欢迎提出。

Q1:第一次安装的时候,按照网上的方法创建了my.ini目录,当时的文件内容如下:

[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8 
[mysqld]
#设置3306端口
port = 3306 
# 设置mysql的安装目录
basedir=D:\sw\mysql-5.7.12-winx64
# 设置mysql数据库的数据的存放目录
datadir=D:\sw\mysql-5.7.12-winx64\data
# 允许最大连接数
max_connections=200
# 服务端使用的字符集默认为8比特编码的latin1字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB

看到这里和我第二步中的my.ini文件内容的区别了么?没错,basedir和datadir的路径写法不一样,“\”和"\\"的区别,这个导致的问题后面会说

然后进入bin目录下,输入mysqld -install,会提示安装成功,继续启动服务,执行net start mysql,会发现服务启动不了,报一下错误:服务正在启动,服务无法启动,服务没有报告任何错误,请键入NET HELPMSG 3534,于是去搜关键字,发现很多人说是缺少data目录,卸载安装5.6.X的就可以,于是看了一下自己的解压文件发现确实没有,但是没想去卸载安装,因为安装别的版本的话这个问题还是存在,下次碰到了还是解决不了啊,如果时版本的问题,官网发布了,那么多人安装,有问题肯定能在网上找到的,于是继续找问题和答案。

继续百度找mysql如何创建data文件,看到了网友的方法:1在压缩文件下创建data空文件夹2创建my.ini文件,内容同Q1,3初始化data文件夹,执行mysqld  --initialize-inscure (不设置root密码,建议使用),这时候问题来了:

D:\sw\mysql-5.7.12-winx64\bin>mysqld –initialize-insecure
mysqld: Can't change dir to 'D: w\mysql-5.7.12-winx64\data\' (Errcode: 2 - No su
ch file or directory)
2016-04-12T02:31:24.980888Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is
 deprecated. Please use --explicit_defaults_for_timestamp server option (see doc
umentation for more details).
2016-04-12T02:31:24.980888Z 0 [Warning] Insecure configuration for --secure-file
-priv: Current value does not restrict location of generated files. Consider set
ting it to a valid, non-empty path.
2016-04-12T02:31:24.980888Z 0 [Note] mysqld (mysqld 5.7.12) starting as process
10788 ...
2016-04-12T02:31:24.981888Z 0 [ERROR] Can't find error-message file 'D:\sw\mysql
-5.7.12-winx64\bin\ w\mysql-5.7.12-winx64\share\errmsg.sys'. Check error-message
 file location and 'lc-messages-dir' configuration directive.
2016-04-12T02:31:24.982888Z 0 [Warning] Can't create test file D: w\mysql-5.7.12
-winx64\data\PC-20150316207.lower-test
2016-04-12T02:31:24.982888Z 0 [Warning] Can't create test file D: w\mysql-5.7.12
-winx64\data\PC-20150316207.lower-test
2016-04-12T02:31:24.983888Z 0 [ERROR] failed to set datadir to D: w\mysql-5.7.12
-winx64\data\
2016-04-12T02:31:24.984888Z 0 [ERROR] Aborting


2016-04-12T02:31:24.985888Z 0 [Note] Binlog end
2016-04-12T02:31:24.986888Z 0 [Note]

执行完后报这个错误,看这个提示Can't change dir to 'D: w\mysql-5.7.12-winx64\data\' (Errcode: 2 - No su
ch file or directory),好像是说当前目录不存在,而且诡异的是 'D: w\mysql-5.7.12-winx64\data\' 这个东西,data我明明是放在“D: sw\mysql-5.7.12-winx64\data\”下面的,s呢?难道是因为sw文件夹的问题?然后我试着新建一个MySql文件夹,将压缩包重新解压到该目录下,继续上面的步骤,会发现执行mysqld  --initialize-inscure通过了,而且在data目录下生成了一堆文件:

心中窃喜,这下总该成功了吧,然后执行mysqld -install,安装成功,激动人心的时刻来了,启动服务,执行net start mysql,然而事与愿违:还是报了服务正在启动,服务无法启动,服务没有报告任何错误,请键入NET HELPMSG 3534

心中一阵沮丧,什么情况啊……

问题还是没解决啊,继续找答案,发现有网友说data目录下是不是没有mysql文件夹,于是我去对照了一下5.6.17的发现他的data目录下有三个文件夹和一堆文件:

按照网友的说法,我将mysql整个文件拷贝到我的data目录下,继续执行net start mysql,终于成功启动了服务。

服务终于启动了,总是觉得有点不完美,我的data目录为什么跟别人的不一样,为什么网上那么多人执行mysqld  --initialize-inscure的时候成功了,没有问题,而我的总是不行呢?说明这个问题还是存在隐患,继续找答案,关键在在于:

mysqld: Can't change dir to 'D: w\mysql-5.7.12-winx64\data\' (Errcode: 2 - No su
ch file or directory)

这个错误应该还是没有解决的,扒拉了半天,有网友提示了my.ini中basedir和datadir的问题,"\"应该用"\\"代替,于是重新解压在"D:\sw"(我想验证是不是目录问题所以重新解压到这个下面验证)下面,修改my.ini,重新按本文开始的步骤执行,完美通过,此时来看data目录会发现该有的文件都有了:

The service already exists!
The current server installed: E:\wnmp\mysql-5.7.14\bin\mysqld MySQL

 

特别提醒,如果出现

D:\MySQL\mysql-5.7.14-winx64\bin>mysqld install
The service already exists!
The current server installed: D:\mysql-5.7.14-winx64\bin\mysqld MySQL

 

使用语句

sc delete MySQL

转载于:https://www.cnblogs.com/grimm/p/5364291.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值