Mysql應(yīng)用安裝后找不到my.ini文件的解決過程
一、背景
我在兩臺電腦上安裝了MySQL Server 8.0,準備繼續(xù)做主從配置,這時候就需要用到my.ini文件進行配置,但是我找不到my.ini文件。
我的安裝目錄中沒有my.ini文件。(這里我的mysql安裝目錄為C:\Program Files\MySQL\MySQL Server 8.0)。

那么我們就需要重新配置一下。
二、刪除原有的mysql服務(wù)
因為我的mysql已經(jīng)用了一段時間,我這里就刪除服務(wù)重新配置。
刪除方法。
進入mysql安裝的bin目錄。在路徑欄輸入cmd命令,即可進入命令提示符。


查看我們mysql服務(wù)的名字。(可以看到這里我們的服務(wù)名字是MySQLD514,服務(wù)名是自定義的,每個人的情況可能不一樣,要自己插。)


命令如下:
# 刪除已安裝的mysql服務(wù) sc delete MySQLD514
三、初始化mysql
# 初始化mysql mysqld --initialize-insecure --user=mysql

四、自行添加my.ini文件
在bin文件夾同級目錄,新建my.ini文件。

將下面腳本復(fù)制到 my.ini文件
# For advice on how to change settings please see # http://dev.mysql.com/doc/refman/5.6/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. [client] default-character-set = utf8mb4 [mysql] default-character-set = utf8mb4 [mysqld] character-set-client-handshake = FALSE character-set-server = utf8mb4 collation-server = utf8mb4_bin init_connect='SET NAMES utf8mb4' # 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:\MySQL datadir = D:\MySQL\data port = 3306 server_id = 1 # 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 = 16M read_rnd_buffer_size = 16M sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
五、新建mysql服務(wù)
輸入命令 ,意思是創(chuàng)建一個名字為MySql的服務(wù),相關(guān)配置文件為C:\Program Files\MySQL\MySQL Server 8.0\my.ini
# 創(chuàng)建mysql服務(wù) mysqld --install "MySql" --defaults-file="C:\Program Files\MySQL\MySQL Server 8.0\my.ini"

再次打開服務(wù),即可看到我們的MySql服務(wù)項。

六、啟動mysql服務(wù)
可以在服務(wù)中直接啟動,也可以在cmd中命令啟動。命令為:
net start MySql

七、設(shè)置數(shù)據(jù)庫密碼
7.1 登錄mysql數(shù)據(jù)庫
在bin目錄啟動cmd。輸入下命令。
mysql -u root -p
這時密碼為空,不需要填寫,直接回車:

7.2 修改root用戶密碼
設(shè)置root用戶密碼為123456
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

設(shè)置退出,再次登錄,即可。
總結(jié)
到此這篇關(guān)于Mysql應(yīng)用安裝后找不到my.ini文件的文章就介紹到這了,更多相關(guān)Mysql找不到my.ini文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
MySQL?數(shù)據(jù)類型及最優(yōu)選取規(guī)則
這篇文章主要介紹了MySQL?數(shù)據(jù)類型及最優(yōu)選取規(guī)則,文章圍繞主題展開詳細的內(nèi)容介紹,具有一定的參考價值,需要的小伙伴可以參考一下,希望對你的學(xué)習(xí)有所幫助2022-08-08
使用MySQL Slow Log來解決MySQL CPU占用高的問題
在Linux VPS系統(tǒng)上有時候會發(fā)現(xiàn)MySQL占用CPU高,導(dǎo)致系統(tǒng)的負載比較高。這種情況很可能是某個SQL語句執(zhí)行的時間太長導(dǎo)致的。優(yōu)化一下這個SQL語句或者優(yōu)化一下這個SQL引用的某個表的索引一般能解決問題2013-03-03
FROM_UNIXTIME 格式化MYSQL時間戳函數(shù)
對MYSQL沒有進行過深入的研究,基礎(chǔ)知識匱乏,一遇到問題只能手冊,看來要把MYSQL的學(xué)習(xí)安排進時間表了。2011-04-04

