mysql5.7版本windows的安装,php
mysql-5.5.46-win32.msi;mysql-5.5.46-winx64.msi;mysql-5.7.12-winx64.msihtml
5.5的版本安装后自动调用初始化和序进行初始化工做(由MySQLInstanceConfig.exe完成),不过5.7版本开始要进行自行初始化.mysql
下面开始说5.7windows版本的安装.sql
1. 先正常安装,固然也能够自定义,选择好安装目录.我这里选择.D:\盘,安装好的路径为windows
“ D:\Program Files\MySQL\MySQL Server 5.7 ”bash
2. 而后copy一下 my-default.ini 复制一分为 my.ini 这个文件。ui
而后修改这个文件。编码
# 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. [mysqld] character-set-server=utf8 collation-server=utf8_general_ci #init_connect='SET NAMES utf8' # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. # basedir = ..... # datadir = ..... # port = ..... # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8
主要有这些地方须要说明日志
# basedir = .....
# datadir = .....
# port = .....
这些是安装目录,数据目录,和程序端口。能够默认code
另外一些主要是说字符编码的问题。在windows上mysql会利用系统默认的编码的GBK。
因此咱们要添加一些配置。
在 mysqld 标端下添加以下:
[mysqld] character-set-server=utf8 collation-server=utf8_general_ci #init_connect='SET NAMES utf8'
[mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8
写好配置文件后,咱们就能够进行初始化了。
到安装好后的目录下的 \bin 执行
mysqld –initialize 能够进行这初始化。 这里也提供--defaults-file=file_name 这个来指定参数。
若是使用了 --defaults-file要把它放在第一个参数,另外一个参数是 --console .
生成的mysql的root用户密码在data目录下的.err日志文件里如图
再就是注册成服务。
mysqld --install mysql --defaults-file="D:\Program Files\MySQL\MySQL Server 5.7\my.ini"
这样就完成了.
咱们能够在windows系统的服务的mysql服务打开mysql服务。
mysql.exe -uroot -p 输入用户密码,会进入mysql中,可是没法使用,会要求咱们先改密码。
能够以使用以下命令:
set password=password("root"); flush privileges;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
网上有人说5.7版本这个mysql数据的user表中没有password这个项了,不能使用,我亲测能够使用,我确实查看了下,user表中确实已经改成authentication_string了。
而后退出,从新使用新密码登录便可。
别忘了,show variables like '%character%';查看相关的字符类型。
为了确保不出理乱码最好使用utf8这种编码。
show variables like '%character%';
这样就OK了。
----------------------------------------------------------------------------------------------------
php.ini(位置就在mysql安装的目录)
# 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. [mysqld] character-set-server=utf8 collation-server=utf8_general_ci # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128M # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # These are commonly set, remove the # and set as required. basedir = D:\Program Files\MySQL\MySQL Server 5.7 datadir = D:\Program Files\MySQL\MySQL Server 5.7\data port = 3306 # server_id = ..... # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128M # sort_buffer_size = 2M # read_rnd_buffer_size = 2M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES [mysql] default-character-set = utf8 [mysql.server] default-character-set = utf8 [mysqld_safe] default-character-set = utf8 [client] default-character-set = utf8
这样的话,初始化和服务安装都不用指定文件