String Find and Replace in MySQL

When creating resource links to assets in our CMS a couple of users had inadvertently linked to the ‘._Filename.doc’ file created by OSX, instead of the intended ‘Filename.doc – on just under 300 files.

Running a quick query to return all the affected resources I used the REPLACE funtion in MYSQL to set all the asset values again (minus the ‘._’)

update TABLENAME
set value = REPLACE(value, '/._', '/')
where value like '%/._%'

Continue reading “String Find and Replace in MySQL”

Mysql not found by PHP

In the middle of a Drupal install on my localhost I received the following error

No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) i…

2AM and in need of a quick fix I just created an alias in the location PHP was looking for mysql.