如何查找和禁用 MySQL 严格模式?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37964325/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 21:53:43  来源:igfitidea点击:

How to find and disable MySQL strict mode?

mysqlcpanelwhmcsstrict-mode

提问by Hamed Atae

Hello everybody I wanted to find this mysql strict mode for whmcs and disable it but i didn't had a progress I'm a newbie so sry if I didn't mention other things Can anyone help me? I'm working on WHM/Cpanel

大家好,我想为 whmcs 找到这个 mysql 严格模式并禁用它,但我没有取得任何进展我是一个新手,所以如果我没有提到其他事情,那么我很抱歉任何人都可以帮助我吗?我正在研究 WHM/Cpanel

回答by Coz

To turn off (or on) mysql strict access from cpanel.

从 cpanel 关闭(或打开)mysql 严格访问。

1, search for 'phpmyadmin', in the search box, click on it

1、搜索'phpmyadmin',在搜索框中,点击它

2, once phpmyadmin is loaded up, click on the 'variables' tab

2、一旦 phpmyadmin 加载完毕,点击“变量”选项卡

3, search for 'sql mode'

3、搜索'sql模式'

then

然后

to turn strict mode on enter

在输入时打开严格模式

STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION

to turn strict mode off, enter

要关闭严格模式,请输入

NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

If you have control of the script you'll be using then it's a good idea to leave strict mode on, it'll alert you to any bugs in your code before they become an issue down the line.

如果您可以控制将要使用的脚本,那么最好保持严格模式,它会在代码中的任何错误成为问题之前提醒您。

回答by Shane Dolim

I currently run a Centos 6.9 server with MariaDB and a multi-cpanel configuration, so for clients, they were unable to disable strict on their own without getting a lack of permission error. This is how you disable it globally:

我目前运行带有 MariaDB 和多 cpanel 配置的 Centos 6.9 服务器,因此对于客户端,他们无法在没有权限错误的情况下自行禁用严格。这是全局禁用它的方法:

Open SSH/Console and verify the current mode:

打开 SSH/Console 并验证当前模式:

# mysql -e "SELECT @@sql_mode;"

+----------------------------------------------------------------------+
| @@sql_mode                                                           |
+----------------------------------------------------------------------+
|STRICT_TRANS_TABLES, ERROR_FOR_DIVISION_BY_ZERO, NO_AUTO_CREATE_USER, |
|NO_ENGINE_SUBSTITUTION                                                |
+----------------------------------------------------------------------+

Locate and edit the "my.cnf" file

找到并编辑“my.cnf”文件

vim /etc/my.cnf

Find and change the following or add the line if it's not present

查找并更改以下内容或添加该行(如果不存在)

Strict Mode Enabled:

启用严格模式:

sql_mode=STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Strict Mode Disabled:

禁用严格模式:

sql_mode=NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

Restart the MySQL Service

重启 MySQL 服务

/etc/init.d/mysql restart

Verify strict mode has been disabled:

验证严格模式已被禁用:

# mysql -e "SELECT @@sql_mode;"

+--------------------------------------------+
| @@sql_mode                                 |
+--------------------------------------------+
| NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION |
+--------------------------------------------+

Done :)

完毕 :)

回答by Kailash Aghera

First of all, to disable MySQL strict mode, you need server's root access. If you don't have it, you can't do it. If you have just cPanel access, that means, you are not the administrator of this server or you don't have root access.

首先,要禁用 MySQL 严格模式,您需要服务器的 root 访问权限。如果你没有它,你就做不到。如果您只有 cPanel 访问权限,这意味着您不是该服务器的管理员,或者您没有 root 访问权限。

To edit your mysql configuration file my.cnf, you will have to access your server via SSH (with root user or sudo access) and then edit /etc/my.cnf file and add following line if it is not present:

要编辑您的 mysql 配置文件 my.cnf,您必须通过 SSH(使用 root 用户或 sudo 访问)访问您的服务器,然后编辑 /etc/my.cnf 文件并添加以下行(如果它不存在):

[mysqld]

[mysqld]

sql_mode="TRADITIONAL,NO_AUTO_CREATE_USER"

sql_mode="TRADITIONAL,NO_AUTO_CREATE_USER"

After editing this file, save it and restart mysql service. Again, you need full root access for your server to change this.

编辑完这个文件后,保存并重启mysql服务。同样,您需要对服务器进行完全 root 访问才能更改此设置。

回答by Shirishkumar Bari

Open my-default.inifile and remove the STRICT_TRANS_TABLESparameter from sql_mode value.

打开my-default.ini文件并STRICT_TRANS_TABLES从 sql_mode 值中删除参数。

[Ex: In localhost xampp the file is at xampp/mysql/my-default.ini]

[例如:在 localhost xampp 中,文件位于 xampp/mysql/my-default.ini]

default value of sql_mode is as below

sql_mode 的默认值如下

sql_mode=STRICT_TRANS_TABLES,NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

change it to

将其更改为

 sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES 

This will disable the strict mode in MYSQL

这将禁用 MYSQL 中的严格模式