1. 程式人生 > >小猿圈Mysql之Mysql綠色版安裝

小猿圈Mysql之Mysql綠色版安裝

後端的人員都會用到資料庫,一大部分人喜歡用mysql,因為mysql是開源的,那麼mysql怎麼安裝呢?如果不注意安裝不成功,很有可能導致刪除不乾淨再一次也很難安裝成功,這篇文章小猿圈加加詳細介紹一下,mysql的安裝過程,大家一起來看看吧。

1、下載MySQL 8.0.16,地址:官網下載

2、解壓到你自己的磁碟

3. 配置Path路徑:系統屬性 => 高階 => 高階 => 系統變數 => path後新增 (如:D:\Tools\mysql-8.0.16-winx64\bin)

4. 在mysql根目錄下新建 my.ini,此檔案是初始化資訊(預設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 = D:\Tools\mysql-8.0.16-winx64

datadir = D:\Tools\mysql-8.0.16-winx64\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

5. 系統管理員模式執行cmd 輸入如下命令

C:\WINDOWS\system32>d:  //進入d盤

D:\>cd "Tools\mysql-8.0.16-winx64\bin" //進入mysql bin檔案下

D:\Tools\mysql-8.0.16-winx64\bin>mysqld --install //執行安裝mysql服務程序

Service successfully installed.  //提示服務安裝成功

D:\Tools\mysql-8.0.16-winx64\bin>mysqld --initialize --console //根據配置檔案初始化mysql,注意檢視輸出的日誌中有臨時密碼, C_:qVsvG6Hxa 就是登入的臨時密碼

A temporary password is generated for root@localhost: C_:qVsvG6Hxa

D:\Tools\mysql-8.0.16-winx64\bin>net start mysql  //啟動mysql服務

D:\Tools\mysql-8.0.16-winx64\bin>mysql -uroot -p  //登入mysql

Enter password:                      //這裡輸入上面的臨時密碼

mysql> alter user root@localhost identified by '123456'; //修改密碼,123456是當前root賬號登陸的密碼

mysql> flush privileges; // 刷新系統表 應用上面修改的新密碼

到處安裝完成!

只要按著上面的步驟走,一般是不會導致mysql會安裝失敗的,一定要一步一步來,這樣防止mysql安裝不成功,後面會很麻煩的,這篇文章就到這了,希望看到這篇文章的朋友們能順利安裝成功,安裝完畢之後,咱們就可以通過命令對資料庫進行增、刪、改、查了,下一篇文章小猿圈加加會詳細寫,可以先去小猿圈預習一下