Tag Archives: mysql

SQL to get WooCommerce product categories (terms)

For an import script I needed to get WooCommerce product categories so I ended up looking the generated query in /var/log/mysql/query.log for get_the_terms($postID, ‘taxonomy_name’) I ended up using the following SQL query to get product categories: SELECT t.*, tt.* FROM … Continue reading

Posted in mysql, sql, Uncategorized, woocommerce, wordpress | Tagged , , , , | Leave a comment

Connect to localhost MySQL from Docker container

To test connection to MySQL/MariaDB server running on localhost from Docker container try: docker run –rm -it –net=host mariadb mysql -u root -h 127.0.0.1 –rm Automatically remove the container when it exits https://docs.docker.com/engine/reference/run/#clean-up-rm -i Keep STDIN open even if not … Continue reading

Posted in docker | Tagged , , | Leave a comment

New path for MySQL query log on OSX

Sometimes during development I need to see what SQL queries are executed and listing them in Console.app is maybe the most convenient solution on OSX. To see queries in Console I just created /etc/mysql/my.cnf with: [mysqld] general_log = 1 # general_log_file … Continue reading

Posted in log, osx, Uncategorized | Tagged , , , , | Leave a comment

Enabling MySQL 5.7 query logging on OSX

I got used to it that sometimes I need to check the queries run by MySQL. After clean OSX upgrade I forgot to enable it. So I added the following to /etc/mysql/my.cnf: [mysqld] sql_mode= general_log = 1 general_log_file = /usr/local/mysql/data/mysqld.query.log … Continue reading

Posted in log, Uncategorized | Tagged , , | Leave a comment

Getting CREATE SQL for single Doctrine entity in Symfony2

I needed to create a new table for a single new Doctrine entity into an existing database. I was in hurry and couldn’t find a solution so came up with my own. Dump the whole SQL into a file: php … Continue reading

Posted in php, Uncategorized | Tagged , , | Leave a comment

Getting ‘doesn’t have a default value’ from MySQL (MariaDB)?

Solution for me from ideas at https://stackoverflow.com/questions/15438840/mysql-error-1364-field-doesnt-have-a-default-values and https://www.farbeyondcode.com/Solution-for-MariaDB-Field–xxx–doesn-t-have-a-default-value-5-2720.html was to remove ‘STRICT_TRANS_TABLES’ from my.cnf. So I ended up with the following in /usr/local/mysql/my.cnf: [mysqlnd] sql_mode=NO_ENGINE_SUBSTITUTION

Posted in osx, sql | Tagged , | Leave a comment

Enable MySQL file logging

Wanted to know what queries are executed so I had to enable it for MariaDB. SET GLOBAL general_log = ‘ON’; SET GLOBAL general_log_file = ‘/var/log/mysql.log’; SET GLOBAL slow_query_log = ‘On’; SET GLOBAL slow_query_log_file = ‘/var/log/mysql-slow.log’; To see the changes: SHOW … Continue reading

Posted in linux, log, monitoring | Tagged , | 1 Comment