第一步:解压mysql,例如解压后的目录在C:\Program Files\mysql-5.6.36-winx64
第二步:配置mysql环境变量,类似配置java的环境变量
计算机右键===>属性===>高级系统设置===>高级===>环境变量
新建系统变量:
变量名:MYSQL_HOME
变量值:C:\Program Files\mysql-5.6.36-winx64
编辑系统变量Path,追加%MYSQL_HOME%\bin;
第三步:进入C:\Program Files\mysql-5.6.36-winx64,将my-default.ini重命名为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.
# basedir = .....
# datadir = .....
# port = .....
# server_id = .....
basedir = C:\Program Files\mysql-5.6.36-winx64
datadir = C:\Program Files\mysql-5.6.36-winx64\data
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
[client]
default-character-set=utf8
第四步:使用管理员操作DOS命令,依次输入:
进入mysql的bin目录:cd C:\Program Files\mysql-5.6.36-winx64\bin
安装mysql:mysqld –install
启动mysql服务器:net start mysql
登陆mysql:mysql –uroot –p 回车,这时提示输入密码,暂时没有密码,直接回车即可
第五步:修改mysql的root账户的密码,继续输入如下命令:
use mysql;
update user set password=password("新密码") where user="root";
flush privileges;
第五步有些版本是错误的,
命令如下:
1、use mysql;
2、alter user ‘root‘@‘localhost‘ identified with mysql_native_password by ‘********‘;
3、flush privileges;
原文地址:https://www.cnblogs.com/topguntopgun/p/11385220.html