windows下MySQL解壓版安裝配置詳細步驟

一、下載MySQL數據庫解壓版並解壓

二、配置環境變量

    在系統變量path後面添加MySQL安裝路徑下的bin目錄;
    例:E:\mysql\bin

三、修改MySQL配置文件

    在MySQL安裝目錄下有一個my-default.ini文件,複製一份,改名爲my.ini,修改裏面的配置。
原始文件my-default.ini:

# 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 = .....
# datadir = .....
# 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 

    修改其中的basedir;datadir;port。
    basedir爲MySQL安裝根路徑,datadir爲MySQL安裝根目錄下的data文件夾路徑。port爲默認端口號。
例:
修改後文件my.ini:

# 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.

[mysql]
 default-character-set=utf8 

[mysqld]
#skip-grant-tables
# 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 = E:\mysql
datadir = E:\mysql\data
port = 3306
# 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服務

    1.以管理員身份打開命令提示符,進入到MySQL安裝路徑bin目錄。執行命令:mysqld -install將mysql安裝到windows的服務。如需移除,執行mysqld --remove移除服務。
    2.輸入命令:mysqld --initialize ,這一步用於初始化data目錄,官方的壓縮包解壓後並沒有data文件夾,運行命令後,自動在根目錄下生成data文件夾。

五、啓動MySQL服務

    在命令提示符執行 net start mysql啓動MySQL服務;執行net stop mysql停止服務。

六、登錄維護MySQL

    MySQL默認用戶名爲root,密碼爲空。初次安裝完成後可以直接進入安裝路徑的bin目錄,執行mysql -u root -p,此時會提示輸入密碼,直接回車跳過,登錄成功。如需設置密碼,執行mysqladmin -uroot -p password <新密碼>命令,會提示輸入舊密碼,舊密碼爲空,直接回車跳過。
    新版本的MySQL中,root用戶的密碼不能爲空,在使用前必須設置密碼。
    1.在配置文件my.ini中,[mysqld]後一行加入skip-grant-tables;
    2.重啓MySQL服務;
    3.執行mysql -u root -p,此時會提示輸入密碼,直接回車跳過,登錄成功。
    4.選擇mysql數據庫。執行use mysql;
    5.對user表執行更新操作。update user set authentication_string=password("你的密碼") where user="root"; 
    6.刷新MySQL的系統權限相關表。執行flush privileges 。刷新後退出,執行quit 。mysql 新設置用戶或更改密碼後需刷新相關表,否則會出現拒絕訪問。
    7.重新啓動MySQL服務。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章