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

查看:225
本文介绍了如何在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图标.

  1. Open MAMP Pro and check your Settings (+,). Make sure Hide Dock Icon is unchecked. If required, uncheck the icon, quit MAMP and restart it.
    Note: This is required to see the menu entries for MAMP. You can hide the Dock Icon again later.

打开MAMP Pro的主窗口,然后通过菜单转到 File > Edit Templates > MySQL > (your version) .
这会打开一个带有您的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=""

In the configuration file look for the line [mysqld] (note the d at the end!).
Right after this line, add a new line with the following text: 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天全站免登陆