如何在 mac 上使用 MAMP 在 mysql 中禁用严格模式 [英] How to disable strict mode in mysql using MAMP on a mac

查看:43
本文介绍了如何在 mac 上使用 MAMP 在 mysql 中禁用严格模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我花了几个小时试图解决这个问题,但我被严重卡住了.我今天安装了最新版本的 mysql,我网站上的一些东西坏了.我相信这与严格的设置有关,IGNORE_SPACE、NO_ZERO_IN_DATE、NO_ZERO_DATE、ERROR_FOR_DIVISION_BY_ZERO、NO_AUTO_CREATE_USER、NO_ENGINE_SUBSTITUTION

I have spent hours trying to figure this out but am seriously stuck. I installed the latest version of mysql today and some things in my website broke. I believe it has to do with strict settings, IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

我试图禁用严格模式只是为了让我的网站正常工作,但这似乎是不可能的.我已经在终端中尝试过这个,但没有运气.

I am trying to disable strict mode just to get my site working but it seems impossible. I have tried this in terminal but no luck.

sudo vim /etc/mysql/conf.d/disable_mysql_strict_mode.cnf


[mysqld] 
    sql_mode="IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION" 

我查看了我能找到的所有 etc 文件夹和其他各种文件夹,但看不到任何类似于 .cnf 文件的内容.

I have looked in every etc folder I can find and other various folders but can't see anything that resembles a .cnf file.

我可以通过 phpmyadmin 临时执行此操作,但如果我关闭 MAMP 或重新启动计算机,我必须再次执行此操作,因为更改不是永久性的.

I can do it temporarily through phpmyadmin but if I close MAMP or restart my computer I have to do it again as the change isn't permanent.

推荐答案

MAMP Pro

  1. 打开 MAMP Pro 并检查您的设置(+).确保 Hide Dock Icon 未选中.如果需要,取消选中该图标,退出 MAMP 并重新启动它.
    注意:这是查看 MAMP 菜单项所必需的.您可以稍后再次隐藏 Dock 图标.

打开 MAMP Pro 的主窗口,然后通过菜单转到 File >编辑模板 >MySQL >(您的版本).
这将打开一个包含您的 MySQL 配置的文本编辑器.

Open the main window of MAMP Pro and via the menu go to File > Edit Templates > MySQL > (your version).
This opens a text editor with your MySQL configuration.

在配置文件中查找[mysqld]行(注意末尾的d!).
在该行之后添加一个新行,其中包含以下文本:sql_mode=""

保存文件,关闭它并重新启动您的 MySQL 服务器.

Save the file, close it and restart your MySQL server.

默认情况下,MAMP free 会在没有 my.cnf 文件的情况下启动 MySQL 服务器,即它使用 MySQL 构建附带的默认配置.所以你必须手动创建一个配置文件:

By default MAMP free starts the MySQL server without a my.cnf file, i.e. it uses the default configuration which comes with the MySQL build. So you have to create a config file manually:

  1. 退出 MAMP(停止服务器)
  2. 在终端中运行以下命令 - 它将在您的文本编辑器应用程序中打开配置文件:
    touch/Applications/MAMP/conf/my.cnf &&open -t/Applications/MAMP/conf/my.cnf

  1. Quit MAMP (stop the servers)
  2. Run following command in the terminal - it will open the config file inside your text editor app:
    touch /Applications/MAMP/conf/my.cnf && open -t /Applications/MAMP/conf/my.cnf

当文件为空时,则添加以下内容:

[mysqld]
sql_mode=""

(当文件不为空时,只需在 [mysqld] 行后面添加一行 sql_mode="")

(When the file is not empty, then simply add the line sql_mode="" right after the line [mysqld])

保存配置文件并关闭文本编辑器;重新启动 MAMP 并启动服务器.

Save the config file and close the text editor; restart MAMP and start the servers.

这篇关于如何在 mac 上使用 MAMP 在 mysql 中禁用严格模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆