首頁  >  文章  >  資料庫  >  mysql5.7.13 環境建構教學(解壓縮版)_MySQL

mysql5.7.13 環境建構教學(解壓縮版)_MySQL

WBOY
WBOY原創
2016-08-20 08:48:131132瀏覽

最近決定學習資料庫,在比較了各個資料庫之後,選擇從mysql入手,主要原因:
 •開源
 •成熟,通用
 •使用者多,社群完善
 •入門簡單

一、下載安裝
 mysql的官方網站下載網址:http://dev.mysql.com/downloads/mysql/
 mysql官網有兩個種版本可供下載,分別是客戶端版本(Recommended Download,也是官網的建議版本)和解壓縮版本(Archive)。我這裡選擇的是解壓縮版本,點選download進行下載,下載完畢後直接將壓縮包解壓縮到您想要安裝mysql的目標路徑即可。
我下載的是5.7.13版本,解壓縮後,得到一個mysql-5.7.13-winx64的資料夾,它包含如下檔:
2016/07/18  14:34   

          .
2016/07/18  14:34              ..
2016/07/18  14:34              bin
2016/05/25  13:50            17,987 COPYING
2016/07/18  14:34              docs
2016/07/18  14:33              include
2016/07/18  14:34              lib
2016/05/25  14:08             1,141 my-default.ini
2016/05/25  13:50             2,478 README
2016/07/18  14:34              share
               3 個檔案         21,606 位元組
               7 目錄 118,994,726,912 可用位元組
至此,下載安裝完畢 

二、設定mysql 

1.配置my.ini
我在這裡將mysql-5.7.13-winx64文件重命名為mysql(原文件名太長了),該文件下的my-default.ini是預設的配置文件,我們這裡需要自己重新實現配置:將my- default.ini複製一份並重新命名為my.ini,並將最將basedir、datadir等參數的檔案目錄替換成你自己mysql所在目錄的路徑。

 # For advice on how to change settings please see
 # http://dev.mysql.com/doc/refman/5.7/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 = C:\mysql
datadir = C:\mysql\data
# port = .....
# server_id = .....


# 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 

我這裡的mysql檔案放在c盤下,所以只要把上面檔案中「c:/mysql」的地方填入你自己的檔案路徑就ok了。 

2.配置環境變數
將你的mysql bin資料夾的路徑加入PATH中,很簡單,不多說了。

三、運行mysql
以管理員身分執行cmd(一定要用管理員身分執行),並進入到mysql的bin檔案中
mysqld --remove
mysqld --install
mysqld --initialize //會產生一個data資料夾
net start mysql //啟動mysql服務
依序執行這三個指令後,打開data資料夾,找到其下error檔案類型的檔案打開,該檔案是本次mysql初始化的log日誌,包括初始化密碼。如果顯示“root@localhost is created with an empty password !”,則為空。然後執行
 mysql -uroot -p
輸入使用者名稱和密碼,顯示“ Type 'help;' or 'h' for help. Type 'c' to clear the current input statement. ”,則表示連線成功。 

四、登入出錯
 
如果登入的時候有問題,顯示“ Access denied for user 'root'@'localhost'”,可以嘗試重新設定設定root密碼:
 1.修改/my.ini檔案,在[mysqld]下新增 skip-grant-tables , 再啟動mysql

 2.然後用空密碼方式使用root使用者登入 MySQL;
 mysql -u root

 3.修改root用戶的密碼;

 mysql> update mysql.user set password=PASSWORD('新密码') where User='root'
mysql> flush privileges;
mysql> quit

 4.重新啟動MySQL,就可以使用新密碼登入了。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn