1.首先到http://dev.mysql.com/ 上下載windows版mysql5.6免安裝zip包。然后將zip包解壓到D:\mysql-5.6.20-winx64下。
2.復制mysql下的my-default.ini, 在同目錄下創建my.ini. my.ini為mysql的配置。最簡單的配置:
1 basedir=D:/mysql-5.6.20-winx64 2 datadir=D:/mysql-5.6.20-winx64/data
我的配置為:
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=13306 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=10240M 34 innodb_log_file_size=4G 35 # Remove leading # to set options mainly useful for reporting servers. 36 # The server defaults are faster for transactions and fast SELECTs. 37 # Adjust sizes as needed, experiment to find the optimal values. 38 # join_buffer_size = 128M 39 # sort_buffer_size = 2M 40 # read_rnd_buffer_size = 2M 41 42 # sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
還可以在my.ini中增加lower_case_table_names=1(默認linux是區分表名大小寫的,加上這句話表示在linux下不區分表名大小寫)
mysql : Lock wait timeout exceeded; try restarting transaction
原因是你使用的InnoDB表類型的時候,
默認參數:innodb_lock_wait_timeout設置鎖等待的時間是50s,
因為有的鎖等待超過了這個時間,所以抱錯.你可以把這個時間加長,或者優化存儲過程,事務避免過長時間的等待.
#innodb_lock_wait_timeout = 50 innodb_lock_wait_timeout = 500 改成500秒
3.設置環境變量PATH。將D:\mysql-5.6.20-winx64\bin加入path中。


4.CMD下面嘗試啟動mysqld --console,並將后台log輸出在屏幕。

5.注冊mysql為windows service. 以后可以使用windows service來安裝mysqld和卸載mysqld的服務.
安裝MySQL服務,一定要進入D:\mysql-5.6.20-winx64\bin目錄執行安裝
mysqld install
卸載MySQL服務
mysqld remove


6.進入服務管理器

7.啟動MySQL服務

8.net start mysql 啟動mysql服務,net stop mysql 停止mysql服務

9.也可以使用mysqladmin命令關閉mysql服務。

10.使用root用戶登錄mysql數據庫

如果MySQL的連接端口不是默認的3306,可以使用下面的命令
mysql -P13306 -u root -p
指定MySQL連接端口13306
如果MySQL的連接服務器IP不是本機或者用戶名不支持本機登陸,可以使用下面的命令
mysql -h機器名或IP地址 -P13306 -u root -p
11.顯示數據庫文件存放路徑和所有數據庫
show global variables like "%datadir%"; --查看數據庫文件存放路徑
show databases; --顯示所有數據庫

12.修改root帳戶的登陸密碼1234:
GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY '1234';

\q 退出MySQL
13.創建數據庫需要指定中文編碼方式

14.查看MySQL存儲引擎
show engines;

15.創建mysql遠程連接用戶,設置最大權限和登陸密碼。
GRANT ALL ON *.* TO 'sa'@'%' IDENTIFIED BY '1234' WITH GRANT OPTION;

還有一些測試mysql安裝的命令:



最后設置打開死鎖開關的命令:
set global innodb_print_all_deadlocks=on
查看開關是否已經打開的命令:
show variables like 'innodb_print_all_deadlocks'
skip-grant-tables:非常有用的mysql啟動參數
在my.cnf文件中增加一行:
skip-grant-tables
或者以命令行參數啟動mysql:
/usr/bin/mysqld_safe --skip-grant-tables &
登陸mysql
mysql
修改管理員密碼:
1 use mysql; 2 update user set password=password('1234') where user='root'; 3 flush privileges; 4 exit;
重啟mysql
