1.首先到http://dev.mysql.com/ 上下載windows版,mysqlinstall,這個軟件mysql爲windows平臺提供安裝解決方案的軟件,。html
2.複製mysql下的my-default.ini, 在同目錄下建立my.ini. my.ini爲mysql的配置。最簡單的配置:mysql
1 basedir=D:/mysql-5.6.20-winx64 2 datadir=D:/mysql-5.6.20-winx64/data
base configsql
個人配置爲:數據庫
1 # For advice on how to change settings please see 2 # http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html 3 # *** DO NOT EDIT THIS FILE. It's a template which will be copied to the 4 # *** default location during install, and will be replaced if you 5 # *** upgrade to a newer version of MySQL. 6 7 [mysqld] 8 character-set-server=utf8 9 10 # Remove leading # and set to the amount of RAM for the most important data 11 # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. 12 # innodb_buffer_pool_size = 128M 13 14 # Remove leading # to turn on a very important data integrity option: logging 15 # changes to the binary log between backups. 16 # log_bin 17 18 # These are commonly set, remove the # and set as required. 19 # basedir = ..... 20 # datadir = ..... 21 # port = ..... 22 # server_id = ..... 23 basedir=D:/mysql-5.6.20-winx64 24 datadir=D:/mysql-5.6.20-winx64/data 25 port=3306 26 27 character-set-server=utf8 28 default-storage-engine=INNODB 29 innodb_data_home_dir=D:/mysql-5.6.20-winx64/data 30 innodb_data_file_path=ibdata1:12M:autoextend 31 innodb_log_group_home_dir=D:/mysql-5.6.20-winx64/data 32 33 innodb_buffer_pool_size=512M 34 # Remove leading # to set options mainly useful for reporting servers. 35 # The server defaults are faster for transactions and fast SELECTs. 36 # Adjust sizes as needed, experiment to find the optimal values. 37 # join_buffer_size = 128M 38 # sort_buffer_size = 2M 39 # read_rnd_buffer_size = 2M 40 41 # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
my.iniwindows
3.設置環境變量PATH。將D:\mysql-5.6.20-winx64\bin加入path中。測試
4.CMD下面嘗試啓動mysqld,並將後臺log輸出在屏幕。ui
5.註冊mysql爲windows service. 之後能夠使用windows service來安裝mysqld和卸載mysqld的服務.編碼
6.進入服務管理器.net
7.啓動MySQL服務3d
8.net start mysql 啓動mysql服務,net stop mysql 中止mysql服務
9.也能夠使用mysqladmin命令關閉mysql服務。
10.使用root用戶登陸mysql數據庫
11.show databases;顯示全部數據庫
12.修改root賬戶的登錄密碼1234:
13.建立數據庫須要指定中文編碼方式
14.查看MySQL存儲引擎
15.建立mysql遠程鏈接用戶,設置最大權限和登錄密碼。
還有一些測試mysql安裝的命令:
若是發生啓動錯誤的狀況,通常是my.ini沒有配置成功。
能夠查看根目錄下的*.err文件,針對具體狀況進行排查。
其中有一種狀況是將ib_logfile0,ib_logfile1刪除之後,重啓便可。