轉載之http://blog.csdn.net/u013283787/article/details/76599794 html
1.首先在mysql官網下載最新版mysql, 附上連接點擊打開連接,根據你的系統型號選擇對應的包下載,大約300多兆,版本號爲5.7.19mysql
下載完以後,解壓縮,是一個標準的mysql文件,如圖sql
2.第二步,配置系統環境變量,桌面→個人電腦→右鍵"屬性"→高級系統設置→環境變量→系統變量→新建數據庫
變量名能夠根據喜愛隨便取,我這裏叫作MYSQL_HOME,變量值是你剛剛下載的mysql文件夾所在的目錄,咱們指向其中的bin目錄,而後一路肯定返回服務器
3.咱們的mysql文件中沒有默認的配置文件,咱們新建一個.ini的配置文件,名字爲my-default.ini,裏邊內容以下:工具
# 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]
# 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 = D:\mysql-server
# datadir = D:\mysql-server\data
# port = .....
# server_id = .....
#設置服務器字符集爲utf8
character_set_server=utf8
collation-server=utf8_general_ci
#設置mysql的安裝目錄
basedir = D:\mysql-server
#設置mysql的數據文件存放目錄
datadir = D:\mysql-server\data
#設置mysql服務所綁定的端口
port = 3306
#設置mysql容許的最大鏈接數
max_connections=15
# 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
[client]
#設置客戶端字符集
default-character-set=utf8
[WinMySQLadmin]
Server = D:\mysql-server\bin\mysqld.exe
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES ui
注意裏面的幾個路徑,必定要修改成你的mysql文件夾所在的路徑,因爲我放的目錄是D:\mysql-server,因此上面的配置路徑都爲這個.net
4.準備安裝mysql,經過命令行工具安裝命令行
首先以管理員身份啓動cmd !!!注意!!!,必定要以管理員身份啓動,不然後面會報錯,提示權限不夠日誌
命令以下: mysqld -install 若是出現如下提示,說明安裝成功
而後開始啓動服務,命令: net start mysql
這時候報錯了,提示沒法啓動,3534 ,咱們經過 mysqld --console命令來查看錯誤日誌
這裏提示,mysql文件夾下沒有\data這個文件或者路徑,這時咱們新建一個
咱們用命令進入到mysql文件夾的路徑,輸入如下命令:
mysqld --initialize-insecure --user=mysql
執行完上面命令後,MySQL會自建一個data文件夾,而且建好默認數據庫,登陸的用戶名爲root,密碼爲空
這時咱們再從新啓動mysql,發現就能正常啓動了
至此.咱們安裝mysql就成功了