Tag Archives: mysql

Enable remote MySQL connections on Turnkey Linux LAMP

I am a big fan of Turnkey Linux. It is great for working on projects locally, though sometimes I need to allow others access to the MySQL server on our LAN. Here are simple instructions for enabling remote MySQL connections and for allowing user access: How to allow remote access to databases | TurnKey GNU/Linux docshttp://www.turnkeylinux.org/docs/database-remote-accesssed -i “s/^bind-address/#bind-address/” /etc/mysql/my.cnf Configure MySQL to accept remote root connections (from any host (‘%’)): (added line breaks for readability)

Count occurrences both greater than, less than, or equal in MySQL

Results of the query

  SELECT COUNT(recycled) AS “Total”, SUM(CASE WHEN recycled = 1 THEN 1 ELSE 0 END) AS “New”, SUM(CASE WHEN recycled > 1 THEN 1 ELSE 0 END) AS “Recycled” FROM (a SELECT phone_number, count(*) AS recycled, sale_date FROM ( SELECT DISTINCT * FROM ( SELECT customers.phone_number, customers.sale_date FROM customers INNER JOIN ( SELECT customers.phone_number FROM customers WHERE sale_date BETWEEN ‘2014-05-23’ AND ‘2014-05-30’) list on customers.phone_number = list.phone_number ORDER BY phone_number DESC, sale_date DESC ) AS multiple_sales ) AS sale_dates_analysis GROUP

Turnkey SSH tunnel for MySQL PHP access

Very useful examples at the Linux Journal: http://www.linuxjournal.com/content/creating-secure-tunnels-ssh and I finally found a connection specification that would work: root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq ld.sock’ (2) root@lamp ~# mysql -h localhost -P 3308 -u root -psomepassword vlmdatabase ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysq ld.sock’ (2) root@lamp ~# mysql -h -P 3308 -u root -psomepassword vlmdatabase The last one

Access MySQL server over SSH tunnel using Navicat

Use the remote server's IP and approriate SSH login credentials

Today was my first time to access a MySQL server over a SSH tunnel in Navicat. After a bit of trial and error I was finally able to achieve success Here are the main things I learned: #1 On the client machine running Navicat, use the same credentials that you would use if you were at the console of the remote server. In this case localhost and port 3306 #2 On the SSH tab, use the remote server’s IP and

Replace () / . characters in phone numbers with dashes (MySQL database)

If you have a MySQL database containing phone number records in varying formats, you may want to standardize them. New records can easily be handled by checking data entry against your desired format (via JS or whatever method you like). However, existing records must be dealt with. That is where an UPDATE statement combined some handy MySQL functions can assist us: // Replace forward slash with dash UPDATE db_phonenumbers SET phone_field = REPLACE(phone_field, ‘/’, ‘-‘) // Replace close parenthesis with

Data truncated for column ‘status’ at row 1 [SOLVED]

Showing the existing enum values for the status field

Recently I encountered the following error: Data truncated for column ‘status’ at row 1 This was specifically in a PHP based web hotel/reservations app that uses MySQL for the database backend. When trying to add a new dropdown option value of ‘departed’, the form submission would always fail with the aforementioned error. Thankfully, the solution was easy once I checked the table/field definitions. The column ‘status’ was of type enum and thus needed to have the ‘departed’ value specifically enumerated in

Enable remote MySQL access (root non-local access)

Often one of the first tasks after setting up a MySQL server is to enable connections from other IP addresses. Here are a some articles that discuss how to setup a user that can access a MySQL database remotely (non-locally). Between the two of them you will have all the info you need to create user accounts for remote MySQL db access If you are in a testing environment you can also enable non-local root access for all databases from

[Err] 2006 – MySQL server has gone away Navicat/WordPress [solved]

Screenshot showing the wait_timeout variable in Navicat Server Monitor

Recently I tried upgrading to the latest version of the WordPress Download Monitor plugin. It did not go well Thus, I tried to revert from a backup made using Navicat. Unfortunately, the restore would fail every time while trying to import my wp_posts table (a pretty important table!) I tried exporting the backup to a SQL dump and importing that. No luck. Finally, I tried resolving the actual ‘MySQL server has gone away’ issue itself and I had success. This tip is

Page 1 of 212