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基…