Saturday, April 14, 2012

Wildcard Host doesn't work in MySQL 5.5.22

I haven't used MySQL for a while. After reinstalled my laptop with Ubuntu 12.04 Beta 2, I decided to use MySQL instead of PostgreSQL to continue my JPA study.

sudo apt-get install mysql-server

I used MySQL Administrator long time ago and now it's replaced with powerful MySQL Workbench. If you have difficulties in installing it, please follow this tutorial.

Everything seems fine, just like when I developed myTunes 6 years ago, except that % for any host doesn't work any more. So if you get

ERROR 1045 (28000): Access denied for user 'user'@'localhost' (using password: YES)

Update Host column from % to localhost for your user account and restart MySQL will solve it.

Update: you can also remove anonymous accounts by executing delete from user where user=''; (Thank you, Dan)


  1. Hi there,
    I had the same problem. If you want to use the wildcard '%' as the host, you have to remove the anonymous accounts called 'Any'.

  2. To be accurate, it's: delete from mysql.user where user= ''

    I spent half a day probing user creation/deletion issue before realizing I was getting random result depending on whether I was connected to mysql db.

    Anyway, thanks a lot for this hints !

  3. Not so far I have found new cool tool to work with mySQL on ubuntu– Valentina Studio. Its free edition can do things more than many commercial tools!!
    I very recommend check it.