windows下mysql-5.7.20绿色免安装版配置与使用
mysql-5.7.20绿解压缩版(免安装)安装配置教程
下载地址
1、添加环境变量
新建系统变量 mysql_home ,并配置变量值为 c:mysql-5.7.20-winx64 ;
编辑用户变量 path ,将%mysql_home%bin 追加到 path 变量值后面。注意不是覆盖。
2、将my-default.ini名称改为:my.ini
下面是参数配置
[mysql] default-character-set = utf8mb4 [mysqld] basedir=c:mysql-5.7.20-winx64 datadir=c:mysql-5.7.20-winx64data bind-address = 0.0.0.0 server-id = 1 init-connect = 'set names utf8mb4' character-set-server = utf8mb4 max_connections = 1000 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 128 max_allowed_packet = 4m binlog_cache_size = 1m max_heap_table_size = 8m tmp_table_size = 16m read_buffer_size = 2m read_rnd_buffer_size = 8m sort_buffer_size = 8m join_buffer_size = 8m key_buffer_size = 4m thread_cache_size = 8 query_cache_type = 1 query_cache_size = 8m query_cache_limit = 2m ft_min_word_len = 4 log_bin = mysql-bin binlog_format = mixed expire_logs_days = 30 log_error = c:mysql-5.7.20-winx64datamysql-error.log slow_query_log = 1 long_query_time = 1 slow_query_log_file = c:mysql-5.7.20-winx64datamysql-slow.log performance_schema = 0 explicit_defaults_for_timestamp #lower_case_table_names = 1 skip-external-locking default_storage_engine = innodb innodb_file_per_table = 1 innodb_open_files = 500 innodb_buffer_pool_size = 64m innodb_write_io_threads = 4 innodb_read_io_threads = 4 innodb_thread_concurrency = 0 innodb_purge_threads = 1 innodb_flush_log_at_trx_commit = 2 innodb_log_buffer_size = 2m innodb_log_file_size = 32m innodb_log_files_in_group = 3 innodb_max_dirty_pages_pct = 90 innodb_lock_wait_timeout = 120 bulk_insert_buffer_size = 8m myisam_sort_buffer_size = 8m myisam_max_sort_file_size = 10g myisam_repair_threads = 1 interactive_timeout = 28800 wait_timeout = 28800
3、 安装mysql服务
mysql-5.7.20提示msvcr120.dll丢失,需要安装vc2015,下载地址https://www.microsoft.com/en-us/download/details.aspx?id=48145
管理员身份在命令提示符下运行
c:>cd mysql-5.7.20-winx64
c:mysql-5.7.20-winx64>cd bin
c:mysql-5.7.20-winx64bin>mysqld -install mysql --defaults-file="c:mysql-5.7.20-winx64my.ini"
4、初始化mysql-5.7.20
data文件夹不为空是不能执行这个命令的。密码可以去进入data文件,打开一个.err结尾的文件查看,如果设置了errorlog那么在mysql-error.log查看密码
c:mysql-5.7.20-winx64bin>mysqld --initialize 自动生成带随机密码的root用户
c:mysql-5.7.20-winx64bin>mysqld --initialize-insecure 自动生成无密码的root用户
5、启动mysql,在命令提示符中运行命令:net start mysql。
c:mysql-5.7.20-winx64bin>net start mysql
mysql 服务正在启动 .
mysql 服务已经启动成功。
6、修改密码
命令如下:
mysql -uroot -p
alter user 'root'@'localhost' identified by 'z123456789';
或者
c:mysql-5.7.20-winx64bin>mysqladmin -uroot -p password
enter password:
new password:
confirm new password:
7、卸载mysql服务
在命令提示符下进入到c:mysql-5.7.20-winx64bin>输入"mysqld -remove"或者"sc delete mysql"执行卸载服务
c:mysql-5.7.20-winx64bin>mysqld -remove
failed to remove the service because the service is running
stop the service and try again
先要停止mysql
net stop mysql