Thursday, October 12, 2017

SQLSTATE[HY000]: General error MySQL: 1364 Field 'coloum' doesn't have a default value, how to solve

With the root access of the mysql, do the following changes

select @@GLOBAL.sql_mode
In my case, I get the following:
ONLY_FULL_GROUP_BY, STRICT_TRANS_TABLES ,NO_ZERO_IN_DATE,NO_ZERO_DATE,
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Copy this result and remove STRICT_TRANS_TABLES. Then perform the following:
set GLOBAL sql_mode='ONLY_FULL_GROUP_BY, NO_ZERO_IN_DATE,NO_ZERO_DATE, 
ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER, NO_ENGINE_SUBSTITUTION'

brew services start mysql

++++++++++++++++++++++++++++++++++++++

How to Disable MySQL Strict Mode?

It’s relatively easy to disable MySQL strict mode in Ubuntu 16.04 LTS. This may work on other versions of Linux such as CentOS. But I’m not testing it. You can let other know if it’s working on the comments section. Start by login in to your VPS as root user with SSH.
Create a new .cnf file.
nano /etc/mysql/conf.d/strict_mode.cnf
Paste the following code into that file,
[mysqld]
sql_mode=IGNORE_SPACE,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
Save and close the file. And then restart MySQL server.
systemctl restart mysql
Open your application and errors should have disappeared.

How to Enable MySQL Strict Mode back on?

You can turn strict mode back on in the future if your application become compatible with it. Just deleting the file you created earlier and the restarting MySQL will turn strict mode back on. Following command will delete the file,
rm /etc/mysql/conf.d/strict_mode.cnf
Restart MySQL,
systemctl restart mysql
That’s it. Feel free to use comments section if you’re having trouble disabling or re-enabling MySQL strict mode.

security header validate

  HTTP Security Headers Check Tool - Security Headers Response (serpworx.com)