溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

MySQL數(shù)據(jù)庫如何安裝和配置

發(fā)布時間:2022-02-19 15:28:09 來源:億速云 閱讀:162 作者:iii 欄目:開發(fā)技術(shù)

本篇內(nèi)容介紹了“MySQL數(shù)據(jù)庫如何安裝和配置”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

MySQL 是一個比較流行的關(guān)系型數(shù)據(jù)庫。與 oracle 數(shù)據(jù)庫相比雖然性能并不如 oracle,但它擁有社區(qū)版,使用社區(qū)版不需要 oracle 授權(quán)(MySQL 現(xiàn)在也屬于 oracle 公司所有),因此很多小型 web 網(wǎng)站都選擇使用它。

下載

到 MySQL 官網(wǎng)進(jìn)行下載。

解壓配置

將下載下來的壓縮包解壓到一個不帶中文,沒有空格的文件夾下(小編直接放F盤符下)。

將解壓的文件夾下的  bin 文件夾添加到環(huán)境變量(path變量)

初始化 data 文件夾

下載下來的 MySQL(5.7版本之后)默認(rèn)是不帶 data 文件夾的,我們需要創(chuàng)建 data 文件夾。

使用管理員權(quán)限運行命令提示符(或者 powershell)運行如下指令:

mysqld --initialize-insecure --user=mysql

執(zhí)行完上面命令后,MySQL 會創(chuàng)建一個 data 文件夾,并且建好默認(rèn)數(shù)據(jù)庫。

登錄的用戶名為root,密碼為空。之后就可以通過命令net start mysql啟動mysql服務(wù)了。

注:一定要使用管理員運行,否則會出現(xiàn)訪問被拒絕等錯誤。

安裝mysql服務(wù)

還是在命令行bin目錄下輸入:mysqld -install

數(shù)據(jù)庫配置

8.0版本不用配置 my.ini my-default.ini),但低版本的需要配置(高版本的數(shù)據(jù)庫也可以添加這個文件來修改數(shù)據(jù)庫的配置)。

# 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

低版本的需要配置兩個屬性

將前面的注釋符號“#”去掉,根據(jù)你的安裝目錄輸入正確的值。

這里 basedir 為你 mysql 的解壓目錄,datadir 為你數(shù)據(jù)庫數(shù)據(jù)的存放目錄。一般放在根目錄下的 data 目錄下。

以我的配置為例,我將文件夾解壓到 F:\mysql-8.0.25-winx64 下,那么 basedir 就是 F:\mysql-8.0.25-winx64,而根據(jù)習(xí)慣(有些開發(fā)者喜歡將data文件夾配置到別的地方),datadir 則為 F:\mysql-8.0.25-winx64\data。

“MySQL數(shù)據(jù)庫如何安裝和配置”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注億速云網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI