在 Windows7 上按照 MySQL5.7

Posted hapday

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在 Windows7 上按照 MySQL5.7相关的知识,希望对你有一定的参考价值。

在 Windows7 上按照 mysql5.7


1、从官网下载最新版本的 MySQL,这里下载的是 mysql-5.7.17-win32;

2、将下载的 mysql-5.7.17-win32.zip 解压到指定的文件夹下,这里的目标文件夹是 E:\develop;

3、复制 my-default.ini 文件并将新的文件命名为 my.ini;

4、根据自己的 MySQL 解压到的目录配置 my.ini 文件,这里的 my.ini 配置如下:
	####################配置文件开始###################

	 # For advice on how to change settings please see

	 # http://dev.mysql.com/doc/refman/5.7/en/server-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


	 [mysqld]
	 character-set-server=utf8 
	 collation-server=utf8_general_ci

	 port=3306

	 basedir  ="E:\develop\mysql-5.7.17-win32"

	 datadir  ="E:\develop\mysql-5.7.17-win32/data/"

	 tmpdir   ="E:\develop\mysql-5.7.17-win32/data/"

	 socket   ="E:\develop\mysql-5.7.17-win32/data/mysql.sock"

	 log-error="E:\develop\mysql-5.7.17-win32/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="E:\develop\mysql-5.7.17-win32\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 的环境变量,在系统区域创建 MySQL_HOME 变量,值为 MySQL 的按照目录,这里的是 E:\develop\mysql-5.7.17-win32;
   将 MySQL_HOME 加入到 path 变量中,即 %MySQL_HOME%\bin;

6、以管理员身份打开命令行工具 CMD 并进入到 MySQL 的命令 bin 目录,这里为 E:\develop\mysql-5.7.17-win32\bin;

7、执行如下命令:
	7.1 mysqld --initialize --user=mysql --console		
	创建用户表,生成如下信息:
		E:\develop\mysql-5.7.17-win32\bin>mysqld --initialize --user=mysql --console
		2017-01-04T01:02:43.711502Z 0 [Warning] ‘NO_ZERO_DATE‘, ‘NO_ZERO_IN_DATE‘ and ‘E
		RROR_FOR_DIVISION_BY_ZERO‘ sql modes should be used with strict mode. They will
		be merged with strict mode in a future release.
		2017-01-04T01:02:44.326080Z 0 [Warning] InnoDB: New log files created, LSN=45790

		2017-01-04T01:02:44.675125Z 0 [Warning] InnoDB: Creating foreign key constraint
		system tables.
		2017-01-04T01:02:44.791639Z 0 [Warning] No existing UUID has been found, so we a
		ssume that this is the first time that this server has been started. Generating
		a new UUID: 802e6595-d219-11e6-bcf8-10604b7f46dc.
		2017-01-04T01:02:44.806141Z 0 [Warning] Gtid table is not ready to be used. Tabl
		e ‘mysql.gtid_executed‘ cannot be opened.
		2017-01-04T01:02:44.814642Z 1 [Note] A temporary password is generated for [email protected]
		localhost: tFhwFqiA)0oQ
	其中的 tFhwFqiA)0oQ 为 MySQL 为我们生成的临时密码,一定要记下来,后面要用到;
	7.2 mysqld install MySQL --defaults-file="E:\develop\mysql-5.7.17-win32\my.ini"
	安装 MySQL 服务;
	7.3 进入到 MySQL 命令行界面:、
		mysql -uroot -p
	7.4 修改用户 root 的密码(必须修改,不然无法通过):
		set password = password(‘123456‘)

8、查看 MySQL 的字符编码:
	SHOW VARIABLES LIKE ‘%character%‘;
	
	mysql> SHOW VARIABLES LIKE ‘%character%‘;
	+--------------------------+-----------------------------------------------+
	| Variable_name            | Value                                         |
	+--------------------------+-----------------------------------------------+
	| character_set_client     | utf8                                          |
	| character_set_connection | utf8                                          |
	| character_set_database   | utf8                                          |
	| character_set_filesystem | binary                                        |
	| character_set_results    | utf8                                          |
	| character_set_server     | utf8                                          |
	| character_set_system     | utf8                                          |
	| character_sets_dir       | E:\develop\mysql-5.7.17-win32\share\charsets\ |
	+--------------------------+-----------------------------------------------+
	8 rows in set, 1 warning (0.00 sec)
	说明我们的字符编码配置都为 UTF8。

9、好了,至此我们完成了 MySQL 的安装,开始愉快的编程之旅吧!
	

  

以上是关于在 Windows7 上按照 MySQL5.7的主要内容,如果未能解决你的问题,请参考以下文章

Windows7+IIS+PHP7+MySQL5.7环境搭建

☆☆☆☆☆☆☆ 一.Windows7下配置免安装版Mysql5.7.21 ☆☆☆☆☆☆☆

MySQL基础环境_安装配置教程(Windows7 64或Centos7.2 64MySQL5.7)

windows7,windows8中mysql5.7的配置my.ini文件在哪

mysql5.7基础 select...order by...asc 按照一个字段进行升序排序

mysql5.7基础 select...order by...desc 按照一个字段进行降序排列