CategoryMySQL

MySQL related information

How to reset/change expired MySQL 5.6 password in Homestead

MySQL 5.6 introduced password expiration, so the password on your Homestead Virtual Machine may expire at some point. SQLSTATE[HY000] [1862] Your password has expired. To log in you must change it using a client that supports expired passwords. To change this you will need to log into MySQL running on Homestead in order to change your password to fix the expiry vagrant ssh mysql -u homestead ...

Quick way to enable MySQL General Query Log without restarting

If you want to quickly enable the MySQL General Query Log without restarting MySQL Server, you can run these couple queries to start outputting all queries to a file located on disk You can then run a command like “tail -f /var/log/mysql/all.log” to see the queries appear as your application runs. Note never enable this on anything other than a development environment, and make sure...

Testing and timing RDS/MySQL scheduled downtime with PHP

Something I was asked at work recently was “if we do this to the server, how long will it be unavailable for?” and usually the answer would be easy… however in certain circumstances you may not know. One of these is Amazon RDS, whereby you don’t really know what happens when you reboot or change the configuration of an instance, it just sort-of happens and eventually...

Use phpMyAdmin with a remote MySQL server

Been doing relatively proprietary work recently, so not much to share other than this little tip. If you want to use phpMyAdmin but for whatever reason the MySQL server you’re using isn’t local, you can change the host by editing line 104 in config.inc.php in the root of phpMyAdmin: $cfg['Servers'][$i]['host'] = 'localhost'; … and optionally the port if required...

Zend Framework, Zend_Db_Table ORDER BY sorting NULL as last instead of first

If you have a group of fields, some of which may be null (such as an address, in which the 1st line of the address may or may not be filled in) then you may want to sort them all so that if null appears in a field, it's sorted to the bottom of the list as opposed to the top (which is the default behaviour) $select = $table->select(); $rowset = $table->fetchAll($select...

Get column names from a Zend_Db_Table object

If you need to get access to the column names of a Zend_Db_Table object (filtering a list of column names so that you discard any that don't match up, for example) then as found on StackOverflow you can do the following:
$table->info(Zend_Db_Table_Abstract::COLS);
Which of course works from within the object itself, so you could write a method such as:

Drupal migration SQL fixes

If you are migrating from a single instance of Drupal to a multi-site installation, you may encounter a problem or two along the way in terms of certain things breaking as they aren't where they used to be. Since Drupal is almost solely reliant upon the database during it's bootstrap process, more often than not if something is misconfigured you can end up with the white screen of death (which...