一、下载解压修改配置文件
1、下载安装包,我下载的是mysql_5.6.24_winx64.zip,解压到D盘的server目录下
2、将根目录下的“my-default.ini”重命名为“my.ini”
3、修改my.ini配置文件如下:
# 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.
# port = .....
# server_id = .....
#mysql的目录
basedir = D:\\server\mysql-5.6.24-winx64
#mysql存放数据的目录
datadir = D:\\server\mysql-5.6.24-winx64\data
#端口
port=3306
#编码
character_set_server=utf8
# 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
innodb_large_prefix=1
innodb_file_format=BARRACUDA
[client]
port=3306
default-character-set=utf8
二、配置环境变量
1、配置环境变量:MYSQL_HOME,值为安装目录:D:\server\mysql-5.6.24-winx64
2、在Path中加上:;%MYSQL_HOME%\bin;
三、安装
1、进入cmd,cd到mysql解压目录的bin目录下,输入如下命令并回车:
mysqld --install MySQL --defaults-file="D:\server\mysql-5.6.24-winx64\my.ini"
2、提示服务安装成功后,输入如下命令启动服务:
net start MySQL
3、输入如下命令登录(第一次登录没有密码,直接按回车过)
mysql -u root -p
4、修改登录密码(其中123为新密码)
set password for root@localhost = password('123');
四、其它说明
1、常用命令
启动服务:net start MySQL
停止服务:net stop MySQL
卸载服务:sc delete MySQL
2、常见错误
如果出现“错误2 系统找不到文件”,检查一下是否修改过配置文件或者是否进入在bin目录下操作,如果配置文件修改正确并且进入了bin文件夹,需要先删除mysql(输入 mysqld -remove)再重新安装(输入 mysqld -install);
如果出现错误1067,那就是配置文件修改错误,确认一下配置文件是否正确。