1. mysql官网: 下载
2.在windows系统环境变量path,加入如下内容
D:\mysql\mysql-5.7.5-m15-winx64\bin;(注意加分号)
3.在D:\Program Files (x86)\mysql-5.7.9-winx64目录下创建一个 my.ini目录文件
4.my.ini内容如下:
[client]
default-character-set=utf8
[mysqld]
port=3306
basedir ="D:\Program Files (x86)\mysql-5.7.9-winx64/"
datadir ="D:\Program Files (x86)\mysql-5.7.9-winx64/data/"
tmpdir ="D:\Program Files (x86)\mysql-5.7.9-winx64/data/"
#socket ="D:\Program Files (x86)\mysql-5.7.9-winx64/data/mysql.sock"
log-error="D:\Program Files (x86)\mysql-5.7.9-winx64/data/mysql_error.log"
#server_id = 2
#skip-locking
max_connections=100
table_open_cache=256
query_cache_size=1M
tmp_table_size=32M
thread_cache_size=8
innodb_data_home_dir="D:\Program Files (x86)\mysql-5.7.9-winx64/data/"
innodb_flush_log_at_trx_commit =1
innodb_log_buffer_size=128M
innodb_buffer_pool_size=128M
innodb_log_file_size=10M
innodb_thread_concurrency=16
innodb-autoextend-increment=1000
join_buffer_size = 128M
sort_buffer_size = 32M
read_rnd_buffer_size = 32M
max_allowed_packet = 32M
explicit_defaults_for_timestamp=true
sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION"
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
####################配置文件结束###################
5.将mysql注册为windows系统服务
打开cmd 给它管理员执行权限
进入cd D:\Program Files (x86)\mysql-5.7.9-winx64\bin 目录下
执行:mysqld install MySQL --defaults-file="D:\Program Files (x86)\mysql-5.7.9-winx64\my.ini"
6.初始化Date目录
mysqld --initialize-insecure
7.启动mysql服务:
在命令行启动mysql命令为: net start mysql
--关闭mysql命令为:net stop mysql
--移除mysql服务:mysqld remove
8.修改root的密码为root
命令行执行:mysql –uroot
mysql>show databases;
mysql>use mysql;
mysql>set password for root@localhost = password('root');
mysql>exit;
9.用新密码登录OK
10.完成.