Category Archives: MySql

Open source database and at the same time the most popular in the world

Mysql export db and time zone

When exporting mysql db to different server and have datetime or timestamp fields then it is very important what the time zone is the other server is.

Check mysql for time zone. For phpmyadmin go to variables and there check time zone variable and then go to the server where you need to import db and check time zone on the linux server itself.

You need to make sure both time zones are the same.

https://linuxize.com/post/how-to-set-or-change-timezone-on-ubuntu-20-04

Or just add --skip-tz-utc to mysqldump. But this is ok for one db but most likely with backup/restore and tar it’s going to be problem. So just use time zone on linux server and restart mysql/mariadb.

https://stackoverflow.com/questions/14886427/mysql-data-export-changes-times

PostgreSQL remote connection

Problem: Cannot connect remotely mysql or postgresql

Solution:

Allow ports 3306 for mysql or 5432 for pgs.

Go to /etc/mysql/mariadb.conf.d/50-server.cnf and change bind-address = 0.0.0.0. Restart mysql pr maria actually.

Go to hestiacp postgresql configuration part. Go and change listen_addresses = ‘*’, remove comment. Restart psg.

Done.

Delete duplicate entries mysql

delete t1 FROM cataloguestext_2 t1
INNER JOIN cataloguestext_2 t2
WHERE
t1.id < t2.id AND
t1.page = t2.page AND
t1.catalogues_id = t2.catalogues_id;

ref https://phoenixnap.com/kb/mysql-remove-duplicate-rows

Adminer without password

Very important sometimes.

Download adminer .php and then change this on line 1152.

login($_e,$F){if($F==””)return to login($_e,$F){if($F==”abc”)return.

Save and you are good to go. Delete after everything has been setup and working ok.

MySQL import/export dump timestamp problem

I have just lost 4 hours today for a simple export import problem. Why it always has to be that way?!?!?

I had to transfer ip of the domain with the data and of course db. Like always everything was smooth but after trying domain (after dns change) I had to pictures online?!

I have tried everything. Problem was simple (after the battle everyone are generals) – it was mysql :

Dump TIMESTAMP columns in UTC (enables TIMESTAMP columns to be dumped and reloaded between servers in different time zones)

Mysql columns were using timestamps because of the start and end date (23:59:59) for local time BUT when exporting that option was clicked and made strange dates on the importing mysql server.

After unchecking this box time was still strange but at least dates were not going -1 day.

Note to myself – ODS and mysql

When importing data you have got from the datacenter (statistical files) use first openoffice .ods format and import it into already built table (copied table with all the structure) and then just import files to that table. Make sure that openoffice sheet is the same name as db table.

If you previously made table (copied table from table you were using before) then the data will just be imported automatically. You might have some problems with columns number but predefined table (copied) must be the same fields count as with .ods file you are importing.

End of note to myself