1. 程式人生 > >MySQL 5.6.26免安裝版配置

MySQL 5.6.26免安裝版配置


首先到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下不區分表名大小寫)

原因是你使用的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