1、下載mysql 5.7.11 zip 安裝包 || 本機以win7 64位系統爲例,若是是32位系統,請下載32位的安裝包html
http://dev.mysql.com/downloads/mysql/mysql
選擇 Windows (x86, 64-bit), ZIP Archive 下載包sql
2、解壓安裝包 | Extracting the Install Archivewindows
D:\victor.min\software\mysql-5.7.11-winx64 #個人解壓目錄
3、建立一個空文件夾,命名爲data, 也能夠隨便命名,用來存放數據ide
# 本機建立在 D:\victor.min\software\mysql-5.7.11-winx64 目錄下,因此最後會看到 D:\victor.min\software\mysql-5.7.11-winx64\data #此文件夾後面會有用到
4、配置一個本身的啓動配置文件 | Creating an Option Fileui
若是本身用沒什麼特別的,就把 D:\victor.min\software\mysql-5.7.11-winx64\my-default.ini 文件copy一份,從新命名爲 my.ini ,修改裏面的幾個參數就行了 || 配置文件以下debug
# 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] # 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 = ..... ######################### # basedir 爲安裝文件解壓後的目錄 | basedir和datadir 可使用相對路徑 # basedir=./.. basedir=D:\\victor.min\\software\\mysql-5.7.11-winx64 # datadir 爲用來存放數據的目錄 # datadir=./../data datadir=D:\\victor.min\\software\\mysql-5.7.11-winx64\\data # port 爲端口號 port=3306 # mar_connections爲最大鏈接數 max_connections=20 collation-server=utf8_unicode_ci character-set-server=utf8 # 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 explicit_defaults_for_timestamp=true sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
5、初始化數據目錄 Initializing the Data Directorycode
固然,按照mysql官方文檔給出的步驟還有一步 Selecting a MySQL Server Type,就是選擇用 mysqld 仍是 mysqld-debug |命令以下server
mysqld --defaults-file="D:\victor.min\software\mysql-5.7.11-winx64\my.ini" --initialize-insecure
注: 一、這個命令很重要,它會初始化 data 目錄,在執行此命令前請先把data目錄下的全部文件先刪除,不然會失敗htm
二、能夠選擇用 --initialize-insecure 或者 --initialize 來初始化,--initialize-insecure 初始化root密碼爲空,若是用 --initialize來初始化,會產生一個隨機密碼
執行成功後你會在data目錄 下看到 mysql,perofrmance_schema,sys目錄,同時還會有一些文件
6、安裝 mysql 服務
mysqld -install
7、啓動 mysql 服務
net start mysql
到這裏,mysql服務就啓動好,咱們就能夠用root進入 mysql
mysql -u root -p
爲了方便,最好將mysql配置到環境變量中去
後記:
若是中途有什麼步驟失敗,必定要執行 mysql 移除命令,而後刪除 data 目錄下的全部文件
mysqld -remove
特別提醒:5.7 和 5.6 不太相同,要本身初始化數據 data 目錄,否則啓動不會成功
###########################################################
mysql 安裝完後可能會用到的語句
SET PASSWORD FOR root=PASSWORD('123456'); ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password'; alter user 'root'@'localhost' identified by '123'; create database victor; CREATE DATABASE IF NOT EXISTS victor default charset utf8 COLLATE utf8_general_ci; create user 'victor'@'localhost' identified by 'victor@123'; flush privileges; create user 'victorremote'@'%' identified by 'victorremote@123'; flush privileges; grant all on victor.* to 'victor'@'localhost' identified by 'victor@123'; flush privileges; grant all on victor.* to 'victorremote'@'%' identified by 'victorremote@123'; flush privileges; ################################ show variables like 'collation_%'; show variables like 'character_set_%'; set collation_connection=utf8_general_ci; set character_set_client=utf8; set character_set_connection=utf8; set character_set_results=utf8;
##########################################################
mysql 配置參數查詢
http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html