mysql5.7版本windows的安裝

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

這樣的話,初始化和服務安裝都不用指定文件

相關文章
相關標籤/搜索