MySQL 下载与配置教程(免安装版)
MySQL 下載與配置教程(免安裝版)
- 說明
- 步驟
此博客已不再維護,更新內容將更新在另一篇博客中,鏈接:https://blog.csdn.net/wangpaiblog/article/details/121571927
筆者的環境:
-
MySQL 5.7.17 32位
-
Windows 10 教育版
說明
-
本教程講述的是 Windows 下 MySQL 手動版的安裝與配置。這往往是喜歡從 CMD 中執行 MySQL 代碼,或者是希望需要下載的文件盡可能小的使用者的偏愛。如果讀者和他們與眾不同,更喜歡站在巨人的肩膀上,可以選擇集成的IDE來避免進行本教程中講述的煩瑣操作。關于這方面的內容,可見筆者的另一篇博客:
MySQL Community 安裝教程:
https://blog.csdn.net/wangpaiblog/article/details/112000033 -
對于 Linux 下 MySQL 的安裝,可見筆者的另一篇博客:
Linux 下 MySQL 安裝教程:
https://blog.csdn.net/wangpaiblog/article/details/120259448 -
閱讀本教程之前,需要在網上下載 MySQL 的壓縮包,這其中包含 my.ini 等文件。筆者很愿意將這些資源免費發布,但由于版權的問題,讀者需要在網上自行下載。如果實在找不到,也可在下方留言聯系。筆者在看到這些消息之后將免費提供,希望讀者收到后不要自由傳播。
自行下載的方法如下:(如果選擇下面的到官網下載,還需要在下載完成之后在 MySQL 目錄下創建一個 my.ini 文件)-
打開 MySQL 官網,找到Community版的下載。選擇Community是因為該版本免費而且是一般使用的版本。具體的流程如下面的圖片所示。
MySQL 的官網是:https://www.mysql.com/
MySQL 下載處的最終網址:https://dev.mysql.com/downloads/mysql/
-
步驟
將得到的 MySQL 解壓文件夾放置在某個你喜歡的磁盤目錄(目錄不能出現中文字符,這里以E盤為例),且可將該文件夾重命名為你喜歡的名稱(同樣的,該名稱不能出現中文字符,這里以 MySQL 為例)。
用文本文檔打開 MySQL 文件夾中的 my.ini 文件,將“
# 設置 MySQL 的安裝目錄 basedir=E:\MySQL
# 設置 MySQL 數據庫的數據的存放目錄 datadir=E:\MySQL\data ”
這幾行中所提到的文件路徑分別改為與當前 MySQL 文件夾有關的正確的路徑。
一個 my.ini 文件的示例如下:
[mysql] # 設置mysql客戶端默認字符集 default-character-set=utf8 [mysqld] #設置3306端口 port = 3306 #skip-grant-tables # 設置mysql的安裝目錄 basedir=E:\mysql # 設置mysql數據庫的數據的存放目錄 datadir=E:\mysql\data # 允許最大連接數 max_connections=200 # 服務端使用的字符集 character-set-server=utf8 # 創建新表時將使用的默認存儲引擎 default-storage-engine=INNODB[client] #default_character_set=utf8修改系統變量:
我的電腦/計算機‐>屬性‐>高級系統設置‐>環境變量‐>(系統變量)path‐>編輯, 將 MySQL 文件夾下的bin放到里面。最后在那個目錄的路徑后面加個英文的分號“;”,然后保存。如我的配置“ E:\MySQL\bin; ”。
在CMD中輸入以下命令:
安裝服務:輸入“ mysqld install ”回車運行。
再輸入“ mysqld --initialize ”初始化data 目錄;(注意:mysqld 后面一定要有空格和兩條“-”)。
啟動服務:接著就是輸入“ net start mysql ”啟動服務。
輸入“ mysql -u root -p ”回車(mysql、root后面都要有空格,u、p前面都是一條“-”),提示你輸入密碼。這個隨機密碼可在 E:\mysql\data 文件夾里文件名后綴為 err 的 文件里找。具體方法是用記事本打開該文件,找到帶password的一行(“ A temporary password is generated for root@localhost: ”)后面的隨機密碼(不包括前后空格),認證通過后進入mysql 后臺。
配置自己的新密碼:“ mysql> set password for root@localhost =password(‘helloworld’); ” (注意:密碼請記住,否則以后無法進入后臺管理系統。)。
輸入“exit”回車退出mysql;輸入“ net stop mysql ”停止mysql服務。
輸入“ show variables like ‘character%’; ”如果都是utf8和binary字符,沒有lartin1字符,則表示配置成功;輸入“ show databases; ”顯示所有的數據庫。
??以上步驟如果有哪一步失敗,可以重啟電腦重來,也可以使用命令 mysqld --console 做進一步判斷。下面是一個輸出窗口的事例,僅供參考。
Microsoft Windows [版本 10.X.XXXXX] (c) 2016 Microsoft Corporation。保留所有權利。C:\windows\system32>e:E:\>cd mysqlE:\mysql>cd binE:\mysql\bin>mysqld install Service successfully installed.E:\mysql\bin>mysqld --initializeE:\mysql\bin>net start mysql MySQL 服務正在啟動 . MySQL 服務已經啟動成功。E:\mysql\bin>mysql -u root -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.17 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> use mysql Database changed mysql> exit ByeE:\mysql\bin>net stop mysql MySQL 服務正在停止. MySQL 服務已成功停止。E:\mysql\bin>net start mysql MySQL 服務正在啟動 . MySQL 服務已經啟動成功。E:\mysql\bin>mysql -u root -p Enter password: ************ Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.17Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> set password for root@localhost =password('helloworld'); Query OK, 0 rows affected, 1 warning (0.00 sec)mysql> show variables like 'character%'; +--------------------------+--------------------------+ | Variable_name | Value | +--------------------------+--------------------------+ | character_set_client | utf8 | | character_set_connection | utf8 | | character_set_database | utf8 | | character_set_filesystem | binary | | character_set_results | utf8 | | character_set_server | utf8 | | character_set_system | utf8 | | character_sets_dir | E:\mysql\share\charsets\ | +--------------------------+--------------------------+ 8 rows in set, 1 warning (0.01 sec)mysql> show databases; +--------------------+ | Database | +--------------------+ | information_schema | | mysql | | performance_schema | | sys | +--------------------+ 4 rows in set (0.00 sec)mysql> exit ByeE:\mysql\bin>net stop mysql MySQL 服務正在停止. MySQL 服務已成功停止。E:\mysql\bin>net start mysql MySQL 服務正在啟動 . MySQL 服務已經啟動成功。E:\mysql\bin>mysql -u root -p Enter password: * ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)E:\mysql\bin>mysql -u root -p Enter password: ******** Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 4 Server version: 5.7.17 MySQL Community Server (GPL)Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> exit ByeE:\mysql\bin>net stop mysql MySQL 服務正在停止. MySQL 服務已成功停止。總結
以上是生活随笔為你收集整理的MySQL 下载与配置教程(免安装版)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: JDBC、DriverManage、JN
- 下一篇: linux cmake编译源码,linu