溫馨提示×

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

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

Mysql應(yīng)用安裝后找不到my.ini文件如何解決

發(fā)布時(shí)間:2022-08-30 11:51:49 來(lái)源:億速云 閱讀:356 作者:iii 欄目:開發(fā)技術(shù)

這篇文章主要介紹“Mysql應(yīng)用安裝后找不到my.ini文件如何解決”,在日常操作中,相信很多人在Mysql應(yīng)用安裝后找不到my.ini文件如何解決問(wèn)題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”Mysql應(yīng)用安裝后找不到my.ini文件如何解決”的疑惑有所幫助!接下來(lái),請(qǐng)跟著小編一起來(lái)學(xué)習(xí)吧!

    一、背景

    我在兩臺(tái)電腦上安裝了MySQL Server 8.0,準(zhǔn)備繼續(xù)做主從配置,這時(shí)候就需要用到my.ini文件進(jìn)行配置,但是我找不到my.ini文件。

    我的安裝目錄中沒有my.ini文件。(這里我的mysql安裝目錄為C:\Program Files\MySQL\MySQL Server 8.0)。

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    那么我們就需要重新配置一下。

    二、刪除原有的mysql服務(wù)

    因?yàn)槲业膍ysql已經(jīng)用了一段時(shí)間,我這里就刪除服務(wù)重新配置。

    刪除方法。

    進(jìn)入mysql安裝的bin目錄。在路徑欄輸入cmd命令,即可進(jìn)入命令提示符。

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

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

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    命令如下:

    # 刪除已安裝的mysql服務(wù)
    sc delete MySQLD514

    三、初始化mysql

    # 初始化mysql
    mysqld --initialize-insecure --user=mysql

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    四、自行添加my.ini文件

    在bin文件夾同級(jí)目錄,新建my.ini文件。

    Mysql應(yīng)用安裝后找不到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)建一個(gè)名字為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"

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

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

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    六、啟動(dòng)mysql服務(wù)

    可以在服務(wù)中直接啟動(dòng),也可以在cmd中命令啟動(dòng)。命令為:

    net start MySql

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    七、設(shè)置數(shù)據(jù)庫(kù)密碼

    7.1 登錄mysql數(shù)據(jù)庫(kù)

    在bin目錄啟動(dòng)cmd。輸入下命令。

    mysql -u root -p

    這時(shí)密碼為空,不需要填寫,直接回車:

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

    7.2 修改root用戶密碼

    設(shè)置root用戶密碼為123456

    ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123456';

    Mysql應(yīng)用安裝后找不到my.ini文件如何解決

     設(shè)置退出,再次登錄,即可。

    到此,關(guān)于“Mysql應(yīng)用安裝后找不到my.ini文件如何解決”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

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

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

    AI