前言
本文主要是介绍如何在Windows64位MySQL配置式安装,一定要一步一步按步骤进行,本人也是根据个人踩过的坑总结的
1.配置环境变量
建议配置MYSQL_HOME变量这样可能不会报错,可能安装了服务,却无法启动,会出现1067的错误,这个很坑)
在系统变量中创建MYSQL_HOME变量:D:mysqlmysql-5.6.15-winx64
添加PATH:%MYSQL_HOME%bin
2.文件配置
本次安装以mysql-5.6.15-winx64为例,将安装包解压之后,进入解压后的目录找到my-default.ini配置文件,这个文件是mysql的主配置文件,修改如下内容指定数据库存放位置
basedir = D:mysqlmysql-5.6.15-winx64 datadir = D:mysqlmysql-5.6.15-winx64data port=3306 max_connections=200 character-set-server=utf8 default-storage-engine=INNODB
代码语言:javascript复制# 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:mysqlmysql-5.6.15-winx64
datadir = D:mysqlmysql-5.6.15-winx64data
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
3.安装服务
在通过管理员身份打开cmd,注意一定是要用管理员身份打开
输入mysqld install MySQL --default-file="D:mysqlmysql-5.6.15-winx64my.ini",提示successfull表示安装成功,
启动MySQL服务>net start mysql,停止可以使用net stop mysql,当然也可以在服务里面进行操作
4.初始化数据库
mysqld --initialize
如果报错的话:
配置文件增加
代码语言:javascript复制[mysqld]
explicit_defaults_for_timestamp=true
这时会在data文件夹下找到一个xxx.err的文件
5.启动服务
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操作数据库。
我正在参与2023腾讯技术创作特训营第二期有奖征文,瓜分万元奖池和键盘手表