Have I mentioned that working with MySQL makes me physically sick?
Apparently yes, I’ve mentioned it once or twice.
Today I have cause to reacquaint myself with it. I needed to get a database and user set up for a third-party piece of software I’m using. So as root I create a database called ‘foo’, and I create a user called ‘bar’ who will be working with said database.
CREATE DATABASE foo;
Query OK, 1 row affected (0.00 sec)
GRANT USAGE ON foo.* TO ‘bar’@'localhost’ IDENTIFIED BY ‘password’;
Query OK, 0 rows affected (0.00 sec)
FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
$ mysql -u bar -ppassword foo
ERROR 1044: Access denied for user: ‘bar@localhost’ to database ‘foo’
$ mysql -h localhost -u bar -ppassword foo
ERROR 1044: Access denied for user: ‘bar@localhost’ to database ‘foo’
Hah. hahahah. Ok.
Take two.
GRANT USAGE ON foo.* TO bar IDENTIFIED BY ‘password’;
FLUSH PRIVILEGES;
$ mysql -h localhost -u bar -ppassword foo
ERROR 1044: Access denied for user: ‘bar@localhost’ to database ‘foo’
Hah.
GRANT ALL ON foo.* TO bar IDENTIFIED BY ‘password’;
$ mysql -h localhost -u bar -ppassword foo
ERROR 1044: Access denied for user: ‘bar@localhost’ to database ‘foo’
GRANT ALL ON foo.* TO ‘bar’@'localhost’ IDENTIFIED BY ‘password’;
$ mysql -h localhost -u bar -ppassword foo
Welcome to the MySQL monitor. Commands end with ; or \g.
FINALLY.
I wonder what incredibly bright person thought “USAGE” was a good synonym for “user exists but can do absolutely nothing until you add lots of permissions”?
I’ve always hated the mysql permissions tables. I think I always will.
Heh, that brings back memories. Yes, “intuitive” and “the MySQL permissioning system” are not concepts that spring to mind at the same time
Things like http://www.computerbits.com/archive/1996/0700/sql3.html make me think that this isn’t MySQL’s fault, but it is in fact in the SQL specification. I might be wrong, though.