Windows64位MySQL配置式安装(绿色版)

一定要一步一步按步骤进行

1.配置环境变量(建议配置MYSQL_HOME变量这样可能不会报错,可能安装了服务,却无法启动,会出现1067的错误,这个很坑)

Windows64位MySQL配置式安装(绿色版)_第1张图片

在系统变量中创建MYSQL_HOME变量:D:\mysql\mysql-5.6.15-winx64

添加PATH:%MYSQL_HOME%\bin

2.文件配置,本次安装以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 

3.安装服务,在通过管理员身份打开cmd,注意一定是要用管理员身份打开

Windows64位MySQL配置式安装(绿色版)_第2张图片

输入mysqld install MySQL --default-file="D:\mysql\mysql-5.6.15-winx64\my.ini",提示successfull表示安装成功,

启动MySQL服务>net start mysql,停止可以使用net stop mysql,当然也可以在服务里面进行操作


4.初始化数据库

mysqld --initialize

如果报错的话:Windows64位MySQL配置式安装(绿色版)_第3张图片

配置文件增加

[mysqld]

explicit_defaults_for_timestamp=true

这时会在data文件夹下找到一个xxx.err的文件

5.启动服务

net start mysql

6.进入数据库,默认是没有密码回车就行

mysql -u root -p

重新设置密码(若提示Can't connect to MySQL server on 'localhost' (10061),说明MySQL服务没起,应先执行net start mysql,若无法启动服务,重启电脑就行了):

7.重新设置密码

set password = password('123456');

再一次提示一定要配置好环境变量MySQL_HOME


新版mysql8安装:可以参考这位同学的博客MySql-8.0.18-winx64 安装与配置_陌小的博客-CSDN博客_mysql-8.0.18-winx64

注意点:

1.需要在bin目录下以管理员身份进行cmd

2.mysqld --initialize --console初始会生成默认默认密码

3.如果不想在每次不想bin目录才能执行mysql命令,可以配置环境变量,其实可以不用配置,一般不用cmd操作数据库。

Windows64位MySQL配置式安装(绿色版)_第4张图片

 

你可能感兴趣的:(Windows电脑开发技巧,java基础,MySQL安装,MySQL命令安装)