MySQL绿色版安装

1、到官网下载安装包 https://dev.mysql.com/downloads/mysql/

2、解压到某个目录,将data目录下的文件删除,如果没有则新建一个data目录

3、修改my.ini配置文件,如果没有则新建

####################配置文件开始###################
 
# For advice on how to change settings please see
 
# http:\dev.mysql.comdoc
efman5.7enserver-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.
 
[client]
default-character-set=utf8

#character_set_server=utf8

#default-storage-engine=INNODB

#innodb_file_io_threads = 2

#innodb_file_per_table = true 

[mysqld]
 
port=3306
 
basedir ="D:mysql"
 
datadir ="D:mysqldata"
 
tmpdir ="D:mysqldata"
 
socket ="D:mysqldatamysql.sock"
 
log-error="D:mysqldatamysql_error.log"
 
server_id = 1

log-bin=mysql-bin
 
#skip-locking
 
max_connections=100
 
table_open_cache=256
 
query_cache_size=202M
 
tmp_table_size=32M
 
thread_cache_size=4
 
innodb_data_home_dir="D:mysqldata"
 
innodb_flush_log_at_trx_commit =1
 
innodb_log_buffer_size=16M
 
innodb_buffer_pool_size=2G
 
innodb_log_file_size=128M
 
innodb_thread_concurrency=8
 
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"
 
#跳过密码验证
#skip-grant-tables 
skip-name-resolve

#bind-address = 0.0.0.0
 
#sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
 

4、将 bin目录配置到环境变量 path下 如:D:mysqlin

5、cmd  以管理员身份运行,并切换到bin目录下。执行安装MySQL服务命令 mysqld –install (可以带服务名,默认为mysql)

6、初始化数据库,执行命令 mysqld --initialize-insecure --user=mysql --explicit_defaults_for_timestamp  (注意data目录必须为空,否则失败)

7、运行:net start mysql 启动服务

8、客户端连接,运行:mysql –uroot –p (注意:将配置文件中的  skip-grant-tables 打开,可以跳过密码验证。登录后需要修改密码,暂时先跳过)

9、登录mysql后执行如下命令,设置密码和打开远程连接 

update mysql.user set authentication_string=password('123456'),Host = '%' where user='root';
FLUSH PRIVILEGES;

到此MySQL安装完成,最后记得把  skip-grant-tables 注释掉。

 安装过程中有时候会报一个错,忘记是啥了。需要先安装这个插件 vcredist_x64,下载地址:https://download.csdn.net/download/u013865056/11241783

原文地址:https://www.cnblogs.com/zhangjinru123/p/11024686.html