mysql 5.7.9 免安装版 安装步骤及修改默认密码

时间:2022-11-21 15:56:58

1.下载解压到任意盘,比如F:\mysql-5.7.9-winx64”
下载地址:http://pan.baidu.com/s/1sjkpa6T (附安装版)
2.在解压目录F:\mysql中新建data空文件夹(必须为空文件夹)
3.新建my.ini,在my.ini内容如下:

 [client]
default-character-set=utf8
[mysqld]
port=3306
basedir ="F:\mysql-5.7.9-winx64"
datadir ="F:\mysql-5.7.9-winx64\data"
tmpdir ="F:\mysql-5.7.9-winx64\data"
socket ="F:\mysql-5.7.9-winx64\data\mysql.sock"
log-error="F:\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="F:\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

####################配置文件结束###################

4.将mysql注册为windows系统服务
具体操作是在命令行中执行以下命令(需要以管理员身份运行命令行):

需要切换到bin目录,否则,会将服务目录指定为C:\Program Files\MySQL\MySQL Server 5.7\mysqld

增加服务命令:mysqld install MySQL –defaults-file=”F:\mysql-5.7.9-winx64\my.ini”

移除服务命令为:mysqld remove

6.执行命令net start mysql启动mysql

修改密码默认密码步骤:
1、首先关闭mysql服务,新开DOS窗口,cd进入mysql安装目录bin目录,输入mysqld –skip-grant-tables,如果等待时间过长,请关闭DOS窗口,直接进入步骤2,如果失败,再来一次即可。
2、新开DOS, 输入mysql,出现mysql> 命令标识符
3、mysql>update mysql.user set authentication_string=password(“Hh214750838”) where user=”root” and Host=’localhost’;
4、mysql>flush privileges;
5、mysql>quit;
6、重启mysql服务,