下载最新版本 MySQL 5.7.13
解压放置到D:Program FilesMySql
配置环境变量
只是在Path后面添加D:Program FilesMySqlin;
修改MySQL配置文件,修改MySQL内的my-default.ini,或者添加一个ini文件
我的修改
# These are commonly set, remove the # and set as required. basedir = D:Program FilesMySql datadir = D:Program FilesMySqldata port = 3306 # server_id = .....
只改了3个
然后就添加到window服务
再启动服务
问题就在这里,其他文章直接就说启动好了,我的就没有
找了很多篇文章,终于解决
清空MySQL中的data文件夹,再执行下面的操作,然后再次启动就ok了
说明:文档表明,使用-initialize生成随机密码,使用-initialize-insecure生成空密码。默认帐号root,后面的-user=mysql不更改
客户端连接
添加MySQL密码
需要注意的是,MySQL5.7版本以后,user表里面的Password字段改名了,改成了authentication_string
执行下面语句就可以
use mysql; #select * from user where user='root'; update user set authentication_string=password('hongda$123456') where user="root";
再执行命令行
mysql>flush privileges; #更新权限
mysql>quit #退出
必须更新权限才能立即使用。
mysql -u root -p
连接其他服务器数据库:
C:UsersqhongDesktop $ mysql -h 18.16.200.46 -u root -p Enter password: *********** Welcome to the MySQL monitor. Commands end with ; or g. Your MySQL connection id is 188286 Server version: 5.7.18-log MySQL Community Server (GPL) Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
安装window服务
安装服务
mysqld --install MySQL
指定配置文件:
mysqld install MySQL --defaults-file="D:Program FilesMySQLmy.ini"
提示安装成功了,但是这时候还是不能使用的,需要修改路径,这里使用sc命令,binpath表示路径(请修改为你的mysqld所在路径),路径后面跟了一个MySQL是mysqld.exe本身的参数
sc config MySQL binpath= "D:Program FilesMySQLinmysqld MySQL"
删除服务:
mysqld --remove MySQL
如果已经安装window服务,但是卸载不了,是因为service缓存问题,可以重启,也可以使用下面命令:
D:Developmenthuishi-server>sc delete MySQL [SC] DeleteService FAILED 1072: The specified service has been marked for deletion. D:Developmenthuishi-server>sc queryex MySQL SERVICE_NAME: MySQL TYPE : 10 WIN32_OWN_PROCESS STATE : 2 START_PENDING (NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN) WIN32_EXIT_CODE : 0 (0x0) SERVICE_EXIT_CODE : 0 (0x0) CHECKPOINT : 0x3 WAIT_HINT : 0x3a98 PID : 13672 FLAGS : D:Developmenthuishi-server>taskkill /pid 13672 /f SUCCESS: The process with PID 13672 has been terminated.
http://jingyan.baidu.com/article/f3ad7d0ffc061a09c3345bf0.html
http://jingyan.baidu.com/article/0f5fb0991636376d8234ea7a.html
http://blog.sina.com.cn/s/blog_759a5a7c01017dj0.html
http://www.jb51.net/article/77858.htm