<p>The <code>STRICT_TRANS_TABLES</code> mode was added to the default SQL mode in MySQL 5.7.5 and is likely causing the error to be thrown:<br>
<a href="https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html" rel="nofollow noreferrer">https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html</a></p>

<p>You can either disable <code>STRICT_TRANS_TABLES</code> mode in your database (there are plenty of articles explaining how), or add default values to your fields (which I would recommend).</p>

CC BY-SA 4.0
2018-06-05T14:13:17.883Z
OK cheers Ben. Will look at adding the default fields.
Lettie
CC BY-SA 4.0
2018-06-05T11:59:50.567Z
2018-06-05T11:59:50.567Z
Ben Croker
<p>We've just switched server for one of our sites and I am now encountering a MySql error on one of our plugins. The MySql version on the new server is 5.7 and throws an error as a field has no default value.</p>

<p>Do we now need to adjust our db model and records to add Null when we define the attributes to any fields that don't have a default value set?</p>

<p>Strange thing is when I look at the database table some fields have been set up with 'Allow Null' set and others haven't and these fields are exactly the same type for example in both model and record file I have these 2 fields one has been set to Allow Null the other hasn't??</p>

<pre><code>'profession' =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
'city'       =&gt;  array(AttributeType::Name, 'maxLength' =&gt; 255, 'required' =&gt; false),
</code></pre>

<p>Any ideas or suggestions?</p>

<p>Running latest craft 2.6.3016 on php 7.1</p>

<p>Cheers</p>

<plugin-development><mysql>
MySql 5.7 error - field doesn't have a default value
# MySql 5.7 error - field doesn't have a default value

(Asked by: username_0 on 2018-06-05)

We've just switched server for one of our sites and I am now encountering a MySql error on one of our plugins. The MySql version on the new server is 5.7 and throws an error as a field has no default value.
Do we now need to adjust our db model and records to add Null when we define the attributes to any fields that don't have a default value set?
Strange thing is when I look at the database table some fields have been set up with 'Allow Null' set and others haven't and these fields are exactly the same type for example in both model and record file I have these 2 fields one has been set to Allow Null the other hasn't??
'profession' =>  array(AttributeType::Name, 'maxLength' => 255, 'required' => false),
'city'       =>  array(AttributeType::Name, 'maxLength' => 255, 'required' => false),

Any ideas or suggestions?
Running latest craft 2.6.3016 on php 7.1
Cheers

**Tags:** plugin-development, mysql


---

## 1 answers

### Answer by username_1 on 2018-06-05. Score: 3

The `STRICT_TRANS_TABLES` mode was added to the default SQL mode in MySQL 5.7.5 and is likely causing the error to be thrown:  
<https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html>

You can either disable `STRICT_TRANS_TABLES` mode in your database (there are plenty of articles explaining how), or add default values to your fields (which I would recommend).

> **Comments:**
> **username_0**: OK cheers Ben. Will look at adding the default fields.  

---

