Tag Archives: MySQL

MySQL: Filtering with Regular Expressions

Today I wanted to list all all users in a database who had been too lazy to uppercase the first letter in their name. But how can you do that in MySQL? With regular expressions such a check would be easy to write, but this was in MySQL, not in for example PHP… but wait a minute… MySQL actually supports Regular Expressions? Yes, it does! I honestly had no clue.

Continue reading MySQL: Filtering with Regular Expressions

How to delete WordPress post revisions

Having revisions on my posts is nice I suppose. But I was starting to get a bit annoyed with the increasingly long list of revisions in each post. And they really did get long. Mainly because I am in a bit of a testing and experimenting phase which means that I have done a lot of adjustments to almost every single post so far because I don’t have 100% control on how I want things or how things will end up looking and so on 😛 There’s also of course all the obligatory spelling errors I only discover after I have clicked Publish 😛

Anyways, I found a nice little MySQL snippet to clear out all of them in a French comment to a blog post. Thought I could share it here. That way I won’t lose it either 🙂

Continue reading How to delete WordPress post revisions

MySQL: How to reset the root account

I just managed to mess up the MySQL root account. Not a smart idea. After some MySQL manual reading and some serious Google-Fu, I figured out how to fix it.

  1. Stop the mysql server
  2. Add the following to the my.cnf file
  3. Start the mysql server
  4. Start a mysql client and run the following query
    REPLACE INTO mysql.user VALUES ('localhost','root',PASSWORD('blah'),'Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0);
  5. Quit the mysql client
  6. Stop the mysql server
  7. Remove what we added to my.cnf in step 2
  8. Restart the mysql server