(轉)Windows下面安裝和配置MySQL(5.6.20)

原文地址:http://www.cnblogs.com/qiyebao/p/3887055.html html

1.首先到http://dev.mysql.com/ 上下載windows版mysql5.6免安裝zip包。而後將zip包解壓到D:\mysql-5.6.20-winx64下。 mysql

2.複製mysql下的my-default.ini, 在同目錄下建立my.ini. my.ini爲mysql的配置。最簡單的配置: sql

basedir=D:/mysql-5.6.20-winx64
datadir=D:/mysql-5.6.20-winx64/data

個人配置爲:數據庫

 

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/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
# 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=D:/mysql-5.6.20-winx64
datadir=D:/mysql-5.6.20-winx64/data
port=13306
character-set-server=utf8
default-storage-engine=INNODB
innodb_data_home_dir=D:/mysql-5.6.20-winx64/data
innodb_data_file_path=ibdata1:12M:autoextend
innodb_log_group_home_dir=D:/mysql-5.6.20-winx64/data
innodb_buffer_pool_size=10240M
innodb_log_file_size=4G
# 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

 

3.設置環境變量PATH。將D:\mysql-5.6.20-winx64\bin加入path中。 windows

4.CMD下面嘗試啓動mysqld --console,並將後臺log輸出在屏幕。 服務器

5.註冊mysql爲windows service. 之後能夠使用windows service來安裝mysqld和卸載mysqld的服務. 測試

安裝MySQL服務,進入D:\mysql-5.6.20-winx64\bin目錄執行安裝 ui

mysqld install

卸載MySQL服務 編碼

mysqld remove

6.進入服務管理器 spa

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 databases;

12.修改root賬戶的登錄密碼1234:

GRANT ALL ON *.* TO 'root'@'localhost' IDENTIFIED BY '1234';

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'
相關文章
相關標籤/搜索