Description of problem: If I specify a user to connect as on the mysql command line I am unable to connect to the database. [root@narsil current]# mysql -u current -D current ERROR 1044: Access denied for user: '@localhost' to database 'current' However, this works root@narsil current]# mysql current -D current This wouldn't bother me, but it looks like the python bindings are hitting the same issue: >>> con = MySQLdb.connect(user="current", db="current") Traceback (most recent call last): File "<stdin>", line 1, in ? File "/usr/lib/python2.3/site-packages/MySQLdb/__init__.py", line 63, in Connect return apply(Connection, args, kwargs) File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 115, in __init__ self._make_connection(args, kwargs2) File "/usr/lib/python2.3/site-packages/MySQLdb/connections.py", line 41, in _make_connection apply(super(ConnectionBase, self).__init__, args, kwargs) _mysql_exceptions.OperationalError: (1044, "Access denied for user: '@localhost' to database 'current'") To work around the bug here I have just given rights to what would be mysql's default user to log in as. (In this case apache.) What's up with user "@localhost"? Version-Release number of selected component (if applicable): mysql-3.23.58-14
I lied. Giving rights to apache with: GRANT ALL PRIVILEGES on current.* to 'apache'@'localhost' ; Doesn't work. The only way I could get the user apache permission to the current db is to do GRANT ALL PRIVILEGES on *.* to 'apache'@'localhost' ; which granted apache all rights everywhere instead.
I think it's working as designed. It looks like you haven't created a local mysql user named 'current', so in the first case the connection instead references the default anonymous-user account (named '@localhost'), which evidently doesn't have permissions to access the database named 'current'. The second example is a redundant specification of the database name 'current', and the user name falls back to your Unix account name, which evidently does correspond to a mysql user with sufficient permissions to connect. See the mysql manual's chapter on user account management. I don't much care for mysql's approach to managing users and privileges, but Red Hat's certainly not going to undertake redesigning it. You could file a bug at www.mysql.com if you think you have arguments that will persuade them to change their design.
I don't much care for mysql either. It looks like I didn't give the user enough permissions to see if it had permissions to the specific database or some such like that. Closing bug...will poke around their bugzilla.