MacOS15.5 MySQL8 開啟 mysql_native_password

MySQL 8 默認關閉了?mysql_native_password, 需要手動開啟。但是MacOS各種坑,氣死個人。

mysql8 內置了?mysql_native_password ,只是沒有開啟。 驗證方式是執行?show plugins; ,返回的結果中應該有?mysql_native_password ,并且是 disabled 狀態。

系統設置,往下拉,找到Mysql,正常情況下你應該是小綠點,active狀態。

進入“Configuration”標簽頁,默認 Configuration file 是沒有勾選的,是空的。請勾選,并配置為 /etc/my.cnf。 并點擊“Apply”,并確定

當然,你可能聽說 Mysql 有很多配置文件, 也可以配置到~/.my.cnf。但這是錯誤的。理論上可以,但實際上不行,為啥我也不知道,我估計又是MacOS的詭異權限問題。

編輯?/etc/my.cnf 文件是需要root的,切換到root用戶的方式,是執行命令 “sudo su - root”.

網上一堆人說,要找 my-default.cnf 文件,它是默認模板文件,復制一下,改一下就行了。扯淡的是,MacOS下根本沒這個文件。這里我直接給出文件內容,你直接復制粘貼到?/etc/my.cnf 即可。

# Example MySQL config file for medium systems.  
#  
# This is for a system with little memory (32M - 64M) where MySQL plays  
# an important part, or systems up to 128M where MySQL is used together with  
# other programs (such as a web server)  
#  
# MySQL programs look for option files in a set of  
# locations which depend on the deployment platform.  
# You can copy this option file to one of those  
# locations. For information about these locations, see:  
# http://dev.mysql.com/doc/mysql/en/option-files.html  
#  
# In this file, you can use all long options that a program supports.  
# If you want to know which options a program supports, run the program  
# with the "--help" option.  
# The following options will be passed to all MySQL clients  
[client]
default-character-set=utf8
#password   = your_password  
port        = 3306  
socket      = /tmp/mysql.sock   
# Here follows entries for some specific programs  
# The MySQL server  
[mysqld]
# default_authentication_plugin=mysql_native_password
mysql_native_password=ON
character-set-server=utf8  
init_connect='SET NAMES utf8' 
port        = 3306  
socket      = /tmp/mysql.sock  
skip-external-locking  
key_buffer_size = 16M  
max_allowed_packet = 1M  
table_open_cache = 64  
sort_buffer_size = 512K  
net_buffer_length = 8K  
read_buffer_size = 256K  
read_rnd_buffer_size = 512K  
myisam_sort_buffer_size = 8M  
# Don't listen on a TCP/IP port at all. This can be a security enhancement,  
# if all processes that need to connect to mysqld run on the same host.  
# All interaction with mysqld must be made via Unix sockets or named pipes.  
# Note that using this option without enabling named pipes on Windows  
# (via the "enable-named-pipe" option) will render mysqld useless!  
#   
#skip-networking  # Replication Master Server (default)  
# binary logging is required for replication  
log-bin=mysql-bin  # binary logging format - mixed recommended  
binlog_format=mixed  # required unique id between 1 and 2^32 - 1  
# defaults to 1 if master-host is not set  
# but will not function as a master if omitted  
server-id   = 1  # Replication Slave (comment out master section to use this)  
#  
# To configure this host as a replication slave, you can choose between  
# two methods :  
#  
# 1) Use the CHANGE MASTER TO command (fully described in our manual) -  
#    the syntax is:  
#  
#    CHANGE MASTER TO MASTER_HOST=<host>, MASTER_PORT=<port>,  
#    MASTER_USER=<user>, MASTER_PASSWORD=<password> ;  
#  
#    where you replace <host>, <user>, <password> by quoted strings and  
#    <port> by the master's port number (3306 by default).  
#  
#    Example:  
#  
#    CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306,  
#    MASTER_USER='joe', MASTER_PASSWORD='secret';  
#  
# OR  
#  
# 2) Set the variables below. However, in case you choose this method, then  
#    start replication for the first time (even unsuccessfully, for example  
#    if you mistyped the password in master-password and the slave fails to  
#    connect), the slave will create a master.info file, and any later  
#    change in this file to the variables' values below will be ignored and  
#    overridden by the content of the master.info file, unless you shutdown  
#    the slave server, delete master.info and restart the slaver server.  
#    For that reason, you may want to leave the lines below untouched  
#    (commented) and instead use CHANGE MASTER TO (see above)  
#  
# required unique id between 2 and 2^32 - 1  
# (and different from the master)  
# defaults to 2 if master-host is set  
# but will not function as a slave if omitted  
#server-id       = 2  
#  
# The replication master for this slave - required  
#master-host     =   <hostname>  
#  
# The username the slave will use for authentication when connecting  
# to the master - required  
#master-user     =   <username>  
#  
# The password the slave will authenticate with when connecting to  
# the master - required  
#master-password =   <password>  
#  
# The port the master is listening on.  
# optional - defaults to 3306  
#master-port     =  <port>  
#  
# binary logging - not required for slaves, but recommended  
#log-bin=mysql-bin  # Uncomment the following if you are using InnoDB tables  
#innodb_data_home_dir = /usr/local/mysql/data  
#innodb_data_file_path = ibdata1:10M:autoextend  
#innodb_log_group_home_dir = /usr/local/mysql/data  
# You can set .._buffer_pool_size up to 50 - 80 %  
# of RAM but beware of setting memory usage too high  
#innodb_buffer_pool_size = 16M  
#innodb_additional_mem_pool_size = 2M  
# Set .._log_file_size to 25 % of buffer pool size  
#innodb_log_file_size = 5M  
#innodb_log_buffer_size = 8M  
#innodb_flush_log_at_trx_commit = 1  
#innodb_lock_wait_timeout = 50  [mysqldump]  
quick  
max_allowed_packet = 16M  [mysql]  
no-auto-rehash  
# Remove the next comment character if you are not familiar with SQL  
#safe-updates  
default-character-set=utf8   [myisamchk]  
key_buffer_size = 20M  
sort_buffer_size = 20M  
read_buffer = 2M  
write_buffer = 2M  [mysqlhotcopy]  
interactive-timeout

然后root用戶下,執行 chmod 777 /etc/my.cnf

接下來有一些高端操作,不解釋,跟著做就好。

先找到mysql根目錄,你可以通過 執行 which mysql 命令獲取,也可以看這里 Error Log的目錄,例如對于?/usr/local/mysql/data/mysqld.local.err ,它的實際mysql根目錄是?/usr/local/mysql/bin。

在mysql根目錄下,執行:

# 均在 root 用戶下執行mv /usr/local/mysql/bin/mysqld /usr/local/mysql/bin/mysqld.bak# 這個文件空的就可以,vim 之后直接 :wq
vim /usr/local/mysql/bin/mylog.tmp.txtchmod 777 /usr/local/mysql/bin/mylog.tmp.txtvim /usr/local/mysql/bin/mysqld

/usr/local/mysql/bin/mysqld 內容:

#!/bin/bashecho "Input arguments: $@"echo "Input arguments: $@" >> /usr/local/mysql/bin/mylog.tmp.txt/usr/local/mysql/bin/mysqld.bak "$@" --mysql-native-password=ON

這樣就配置完了,需要重啟mysql服務(每次啟動都要輸管理員密碼,確實很麻煩)。經過上述的修改,啟動狀態就無法在這里看到了,會永遠都是紅點。那如何驗證是否啟動成功呢?可以執行:

ps -ef | grep mysql? ?看有沒有 mysqld.bak + 一大串參數 的進程,如果有就是成功了。沒有就是失敗了。

失敗日志可以執行??tail -f /usr/local/mysql/data/mysqld.local.err? 來查看

命令執行情況可以執行?tail mylog.tmp.txt? 查看,每次執行命令都會記錄下來。如果過幾秒就多一條命令,說明服務在不斷重啟。

正常情況下,應該不會報錯。你通過?ps -ef | grep mysql? 看到相關進程,就可以嘗試連接一下數據庫測試了,執行?show plugins; 應該能看到?mysql_native_password 是 active 狀態

那么如何重啟mysql服務呢?因為系統設置里一直都是紅點,根本沒有stop按鈕,所以你要通過?ps -ef | grep mysql? 查看進程號,直接kill掉。? ?然后再從系統設置里再啟動一次,完成重啟。

?

上面整個操作的原理,就是替換原本的?mysqld 文件,改成我們自己的shell文件,我們的shell文件再調用原本的mysqld文件,這樣我們就能在中間加參數,把?--mysql-native-password=ON 加上去。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/web/83887.shtml
繁體地址,請注明出處:http://hk.pswp.cn/web/83887.shtml
英文地址,請注明出處:http://en.pswp.cn/web/83887.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

Git分頁器和Node.js常見問題解決方式

Git分頁器(pager)常見問題解決方式&#xff0c;在Windows PowerShell中經常出現。以下是幾種解決方法&#xff1a; 臨時解決方法 按回車鍵繼續 - 按照提示按RETURN&#xff08;回車鍵&#xff09;即可繼續顯示分支列表按 q 鍵退出 - 如果卡在分頁器界面&#xff0c;按 q 鍵退…

module type中獲取__dirname和__filename

module type中獲取__dirname和__filename import { fileURLToPath } from url// 獲取當前文件的目錄路徑&#xff08;ES模塊中的__dirname替代方案&#xff09; const __filename fileURLToPath(import.meta.url) const __dirname path.dirname(__filename)

多維度剖析Kafka的高性能與高吞吐奧秘

在當今大數據與實時處理盛行的時代&#xff0c;Kafka作為一款卓越的分布式消息系統&#xff0c;憑借其令人驚嘆的高性能與高吞吐能力&#xff0c;成為眾多企業構建實時數據處理架構的首選。接下來&#xff0c;我們將從多個關鍵維度深入探究Kafka實現高性能與高吞吐的核心要素&a…

2025虛幻游戲系統積累

2025虛幻游戲系統積累 前言 積累一下虛幻的游戲系統。 之前寫了2025虛幻人物模型積累-CSDN博客&#xff0c;算是解決了人物模型的問題。現在增加游戲玩法。畢竟無中生有難度有點大&#xff0c;照葫蘆畫瓢難度可以降低一點點。 內容 首先第一個就是 這個游戲demo很值得參考…

HTTPS握手過程中的隨機數機制詳解

在HTTPS/TLS握手過程中&#xff0c;隨機數扮演著至關重要的安全角色。這些隨機數不僅參與密鑰生成&#xff0c;還提供了防止重放攻擊等安全特性。下面我將全面解析握手流程中的隨機數機制。 HTTPS 握手流程中的隨機數機制解析 1. 客戶端發起連接&#xff1a;生成 Client Rand…

MIPI CSI協議中的?像素數據到字節的映射

MIPI CSI協議中的?像素數據到字節的映射?&#xff08;Mapping of pixel values to bytes&#xff09;是指將圖像傳感器輸出的像素值&#xff08;通常以非8比特整數形式表示&#xff09;轉換成適合在8位寬的物理傳輸接口上傳輸的字節序列的過程15。 其核心含義和技術要點如下…

47 C 語言指針與數組核心詳解:字符指針 VS 字符數組、數組操作、字符串處理、編程實戰案例

1 字符指針 1.1 概述 字符指針變量&#xff08;簡稱字符指針&#xff09;是 C 語言中的一種指針類型&#xff0c;用于指向字符或字符串&#xff08;字符數組、字符串字面量&#xff09;。字符指針通常用于處理字符串&#xff08;字符數組&#xff09;&#xff0c;可以方便地進…

gird 網格布局學習

屬性 1、grid-template-columns 用來定義 網格容器的列軌道&#xff08;columns&#xff09; 的尺寸和數量。它允許你設定網格的列布局&#xff0c;控制列的寬度和排列方式。 // 使用示例 // 你可以使用固定的長度單位來定義每一列的寬度。例如 1、grid-template-columns: 100…

git最常用命令

本地身份 git config --global user.name "酒劍仙" git config --global user.email "xxxxqq.com"創建.gitignore文件 git init鏈接服務器 git remote add origin https://gitee.com/greentran/你的項目.git提交本地 git add .查看本地提交 git statu…

值類:Kotlin中的零成本抽象

Kotlin的值類&#xff08;Value Class&#xff09;是一種強大的類型安全工具&#xff0c;允許開發者創建語義明確的類型&#xff0c;并保持運行時零成本。 假設系統中存在用戶的概念&#xff0c;用戶擁有名字和電子郵箱地址。用戶名和電子郵箱地址都是長度不超過120個字符的字…

arm64版BC-liunx-for-euler與X86_64版OpenEuler從源碼安裝git-lfs

1.arm64版BC-liunx-for-euler安裝git-lfs 檢查系統版本信息 uname -a Linux bms-42068966-004 5.10.0-136.49.0.127.10.oe2203.bclinux.aarch64 #1 SMP Tue Oct 10 14:09:09 CST 2023 aarch64 aarch64 aarch64 GNU/Linux 下載git-lfs構建腳本和源碼 git clone https://gite…

2025國家衛健委減肥食譜PDF完整版(免費下載打印)

《成人肥胖食養指南&#xff08;2024年版&#xff09;》發布&#xff1a;科學減肥&#xff0c;從這里開始? 在這個追求健康與美的時代&#xff0c;減肥成為了許多人關注的熱點話題。國家衛健委正式發布了《成人肥胖食養指南&#xff08;2024年版&#xff09;》&#xff0c;為我…

Android 手機如何實現本地視頻音頻提取?實戰教程來了

我們經常會遇到這樣的需求&#xff1a;比如看到一段喜歡的短視頻&#xff0c;想把里面的背景音樂保存下來&#xff1b;或者需要從一段課程視頻中提取語音內容用于學習。這時候&#xff0c;將手機視頻轉換成 MP3 音頻就是一個非常實用的功能。 今天就來教大家如何使用一款簡單好…

STM32項目---汽車氛圍燈

一、藍牙模塊驅動 1、怎么使用藍牙模塊呢&#xff1f; 1&#xff1a;首先&#xff0c;先通過串口調試助手驗證藍牙模塊是否正常使用。先連接好 2&#xff1a;打開串口調試軟件配置好 3&#xff1a;發送測試指令&#xff1a;AT\r\n,返回OK&#xff0c;則說明連接正確&#xff…

python+uniapp微信小程序的共享雨傘租賃系統

目錄 技術棧介紹具體實現截圖系統設計研究方法&#xff1a;設計步驟設計流程核心代碼部分展示研究方法詳細視頻演示試驗方案論文大綱源碼獲取/詳細視頻演示 技術棧介紹 Django-SpringBoot-php-Node.js-flask 本課題的研究方法和研究步驟基本合理&#xff0c;難度適中&#xf…

一次生產故障引發的JVM垃圾回收器選型思考:徹底掌握垃圾回收原理及通用配置!

寫在前面的話 前幾天凌晨2點&#xff0c;我被一通電話驚醒——線上交易系統出現了嚴重的延遲問題&#xff0c;用戶支付請求響應時間從平時的100ms飆升到了5秒&#xff0c;客服電話都被打爆了。 經過緊急排查&#xff0c;我們發現罪魁禍首竟然是JVM的垃圾回收器&#xff01;當…

學習日記-day30-6.15

完成目標&#xff1a; 知識點&#xff1a; 1.DDL和DML的補充 知識點 核心內容 重點 快速創建表 使用CREATE TABLE...AS SELECT語句基于現有表快速創建新表 結構和數據復制 vs 僅復制結構&#xff08;WHERE 12&#xff09; 數據刪除操作 DELETE FROM逐條刪除 vs TRUNCAT…

從檢測到智能質控:IACheck如何成為TIC機構的AI中臺?

一、TIC行業為何亟需AI質控&#xff1f; 過去十年&#xff0c;中國的TIC&#xff08;Testing, Inspection, Certification&#xff09;行業年均增長超過10%。無論是消費品、環境監測&#xff0c;還是工業制造、出口貿易&#xff0c;對“第三方檢測報告”的依賴程度持續加深。 …

cka-1.32考題

1、HPA自動擴縮容 考題 &#xff08;考試的考題內容&#xff0c;只有下面方框里的內容&#xff09; 你必須連接到正確的主機。不這樣做可能導致零分。 [candidatebase] $ ssh cka000050 Task 在 autoscale namespace 中創建一個名為 apache-server 的新 HorizontalPodAut…

DeepSeek 技術原理詳解

引言 DeepSeek是一種基于Transformer架構的大型語言模型&#xff0c;它在自然語言處理領域展現出了卓越的性能。本文將深入探討DeepSeek的技術原理&#xff0c;包括其架構設計、訓練方法和優化策略&#xff0c;并結合代碼實現進行詳細講解。 Transformer基礎架構 DeepSeek基…