Executing a SQL query from a script in Linux

It was necessary recently to write a script that executes a sql query into the MySQL database. Example content: In order for the script to run automatically, open the crontab file in any text editor (in the nano editor CTRL+X for the output and y/n for saving or canceling the changes): Add the following line […]

How to change MySQL database encoding and its tables

Here is an example of changing the MySQL encoding of a database and tables. Before any actions on important data it is necessary to make a backup copy, for example: For the test, we will connect to MySQL and create a couple of new databases without specifying the encoding and specifying: Create a test table […]

How to create a MySQL user and configure access rights

To create a user, we first connect to the MySQL server console: Let’s see what users are: Create a user (where localhost is specified from where the user can connect, you can specify the IP address, localhost – from the local machine where the MySQL server itself, or % from any addresses): If you intend […]

The solution of error “ERROR 1067 (42000) at line 211: Invalid default value for ‘blablabla'”

I noticed once when importing a sql file the following error: ERROR 1067 (42000) at line 211: Invalid default value for ‘blablabla’ It arises because new versions of MySQL server use strict mode and parameters such as NO_ZERO_DATE do not allow entering date values like ‘0000-00-00’ into the database. Connect to mysql server: Execute a […]