1.下载官方安装包(http://www.mysql.com/downloads/),此zip包是没有安装器的(*.msi),也没有辅助配置的自动程序。
2.解压zip包,将文件放入指定目录,如:D:\MySQL5.7.11
3.添加环境变量:
MYSQL_HOME=D:\MySQL5.7.11
PATH=%MYSQL_HOME%\bin;%PATH%
4.将目录内的my-defaults.ini重命名为my.ini,添加配置如下(具体细节根据实际情况自行修改):
[mysqld]
basedir=D:/MySQL5.7.11
datadir=D:/MySQL5.7.11/data
tmpdir=D:/MySQL5.7.11/tmp
port=3306
socket=/tmp/mysql.sock
character-set-server=utf8
default-storage-engine=INNODB
server_id=1
max_allowed_packet=1M
tmp_table_size=16M
key_buffer_size=8M
join_buffer_size=128M
sort_buffer_size=2M
read_buffer_size=8M
read_rnd_buffer_size=8M
net_buffer_length=1M
thread_stack=2M
thread_cache_size=8
max_connections=64
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [client]
port=3306
socket=/tmp/mysql.sock
default-character-set=utf8
5.创建D:\MySQL5.7.1.\data和D:\MySQL5.7.1.\tmp目录
6.将mysql加入windows服务组:
mysqld --install MySQL --defaults-file=D:/MySQL5.7.11/my.ini
7.初始化mysql:
mysqld --initialize-insecure
8.启动mysql:
net start MySQL
9.登录mysql(此时root密码为空):
mysql -u root
10.设置root密码为admin:
mysql -u root
mysql>set password for 'root'@'localhost' = password('admin');
mysql>flush privileges;
11.退出后重新登录验证新密码:
mysql -uroot -padmin
12.关闭mysql服务:
net stop MySQL
*搞定,手工!