Written by on

When i upgraded my Prestashop server from Ubuntu 14.04 to Ubuntu 16.04, my Prestashop products were not displayed on category pages. Who did take them from me ? My server has been hacked ?

Actually, this is a database issue due to Mysql 5.7 on Ubuntu 16.04. Do you have a plan to download Prestashop and install your ecommerce website on an Ubuntu server ? It's a good idea but this issue will effect to any Prestashop websites running on Ubuntu 16.04. Take some minutes here to know how to fix it!!!

I received a message from @Casper_O on Twitter that products on our Prestashop demo page were not displayed on category pages that running on an Ubuntu 16.04 LTS server with Apache, Pagespeed, PHP 7 and MySQL 5.7. Take a few minutes on it, i saw few MySQL queries failed and the products were not displayed correctly.

I didn’t took long for me to realized that this is due to MySQL Strict mode. Prestashop 1.6 ( and Prestashop 1.7 ? ) are not compatible with MySQL strict mode. We have to turn it off to fixed the error. Another applications that are not compatible with MySQL Strict Mode. So if you have a plan to run your Prestashop website on Ubuntu 16.04, you should consider disabling Strict mode.

What is MySQL Strict Mode?

Strict mode handles how invalid or missing values in SQL queries. It’s available in both MySQL and MariaDB and enabled by default in MySQL 5.7 and MariaDB 10. Although disabling it is safe on most cases, sometimes it may cause unexpected errors in database tables.

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. Start by login in to your VPS as root user with SSH and create a new .cnf file :

sudo 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_AUT

Save and close the file. And then restart MySQL server.

service mysql restart

That's all :)