我是从mysql官网下载的是mysql-5.7.19-winx64版本,解压之后没有data,导致一直启动不了,出现问题:MySQL 服务无法启动。 服务没有报告任何错误。 请键入 NET HELPMSG 3534 以获得更多的帮助。解决办法如下:
不要自己创建data文件夹。
1、配置(不要急着使用,最好先配置),过程:计算机—>系统属性—>高级系统配置—>环境变量
2、修改配置文件,同样的,这个版本默认是没有配置文件my-default的,需要自己新建一个,并粘贴如下内容:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
# basedir = D:\Softwares\MySQL\mysql-5.7.19-winx64
# datadir = D:\Softwares\MySQL\mysql-5.7.19-winx64\data
# port = 3306
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
主要是修改basedir和datadir的地址;
3、安装mysql,
首先,以管理员身份运行cmd(必须以管理员身份运行,否则权限不够,会出错)
接着,进入D:\Program Files\MySQL Server 5.6\bin目录,
然后,执行命令mysqld –install
,若无错,则会提示安装成功。
注:若之前安装过mysql,但由于某种原因未卸载干净,当再次安装mysql时,会提示此服务已存在。可用sc delete mysql命令,删除之前的版本,再执行mysqld –install命令。
4、安装好MySQL之后,先不要启动,输入mysqld --initialize 进行初始化(注意是两个“-”符号)然后就会发现目录下多了一个data文件夹,里面有很多文件。
5、启动mysql服务器。在dos界面输入net start mysql会发现已经可以启动了。
6、登陆mysql.在cmd中,输入 mysql -u root -p
,第一次登录没有密码,直接回车,登陆成功。
但是就在第6步,出错了。解决方案参照http://www.cnblogs.com/xixibaby/p/6549872.html