Bug 145284 - mysql client can't connect with specified user
Summary: mysql client can't connect with specified user
Keywords:
Status: CLOSED NOTABUG
Alias: None
Product: Fedora
Classification: Fedora
Component: mysql
Version: 3
Hardware: All
OS: Linux
medium
medium
Target Milestone: ---
Assignee: Tom Lane
QA Contact: David Lawrence
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-01-16 23:20 UTC by Jack Neely
Modified: 2013-07-03 03:03 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2005-01-20 20:08:38 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)

Description Jack Neely 2005-01-16 23:20:54 UTC
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

Comment 1 Jack Neely 2005-01-16 23:38:48 UTC
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.

Comment 2 Tom Lane 2005-01-17 01:56:20 UTC
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.

Comment 3 Jack Neely 2005-01-20 20:08:38 UTC
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.


Note You need to log in before you can comment on or make changes to this bug.