本文主要是介绍如何在Windows64位MySQL配置式安装,一定要一步一步按步骤进行,本人也是根据个人踩过的坑总结的
建议配置MYSQL_HOME变量这样可能不会报错,可能安装了服务,却无法启动,会出现1067的错误,这个很坑)
在系统变量中创建MYSQL_HOME变量:D:\mysql\mysql-5.6.15-winx64
添加PATH:%MYSQL_HOME%\bin
本次安装以mysql-5.6.15-winx64为例,将安装包解压之后,进入解压后的目录找到my-default.ini配置文件,这个文件是mysql的主配置文件,修改如下内容指定数据库存放位置
basedir = D:\mysql\mysql-5.6.15-winx64 datadir = D:\mysql\mysql-5.6.15-winx64\data port=3306 max_connections=200 character-set-server=utf8 default-storage-engine=INNODB
# 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 = .....
# datadir = .....
# port = .....
# server_id = .....
basedir = D:\mysql\mysql-5.6.15-winx64
datadir = D:\mysql\mysql-5.6.15-winx64\data
port=3306
max_connections=200
character-set-server=utf8
default-storage-engine=INNODB
# 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
在通过管理员身份打开cmd,注意一定是要用管理员身份打开
输入mysqld install MySQL --default-file="D:\mysql\mysql-5.6.15-winx64\my.ini",提示successfull表示安装成功,
启动MySQL服务>net start mysql,停止可以使用net stop mysql,当然也可以在服务里面进行操作
mysqld --initialize
如果报错的话:
配置文件增加
[mysqld]
explicit_defaults_for_timestamp=true
这时会在data文件夹下找到一个xxx.err的文件
net start mysql
进入数据库,默认是没有密码回车就行
mysql -u root -p
重新设置密码(若提示Can't connect to MySQL server on 'localhost' (10061),说明MySQL服务没起,应先执行net start mysql,若无法启动服务,重启电脑就行了):
重新设置密码
set password = password('123456');
再一次提示一定要配置好环境变量MySQL_HOME
注意点:
1.需要在bin目录下以管理员身份进行cmd
2.mysqld --initialize --console初始会生成默认默认密码
3.如果不想在每次不想bin目录才能执行mysql命令,可以配置环境变量,其实可以不用配置,一般不用cmd操作数据库。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。