LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-13-2011, 05:00 AM   #1
Harry2o
LQ Newbie
 
Registered: Aug 2006
Posts: 12

Rep: Reputation: 0
Cannot access MySQL server other than user=root


Hi,

I've tried every manual there is for creating new MySQL users ... but without success.
I keep getting
Code:
ERROR 1045 (28000): Access denied for user 'test'@'localhost' (using password: YES)
even though I just created it with all privileges ... WITH a password that I DO remember .

Fortunately I still have access via the MySQL root user (so I try not to disturb that user, because I have had computers with THAT account not accessible as well - even WITH resetting the password via skip-grant-tables).


Any ideas what's wrong with my grant tables?
 
Old 04-13-2011, 05:36 AM   #2
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

Can you post the exact commands you used to create a new user and grant him privileges? Did you get any error or warning when running those commands? Also enter as root in a MySQL console and execute:
Code:
show grants for 'test'@'localhost';
and post the output here.

Kind regards,

Eric
 
Old 04-13-2011, 07:09 AM   #3
Harry2o
LQ Newbie
 
Registered: Aug 2006
Posts: 12

Original Poster
Rep: Reputation: 0
you got it

Code:
harry@dragonfly:~$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 78687
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)
[...]

mysql> create user 'test'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'test'@'%' with grant option;
Query OK, 0 rows affected (0.00 sec)

mysql> show grants for 'test'@'%';
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for test@%                                                                                                              |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'test'@'%' IDENTIFIED BY PASSWORD '*2470C0C06DEE42FD1618BB99005ADCA2EC9D1E19' WITH GRANT OPTION |
+--------------------------------------------------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> Bye
harry@dragonfly:~$ mysql -u test -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'test'@'localhost' (using password: YES)
harry@dragonfly:~$
And yes, I did enter the password correctly
 
Old 04-13-2011, 07:19 AM   #4
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Quote:
Originally Posted by Harry2o View Post
you got it
And yes, I did enter the password correctly
Hi,

Thanks for the info. I think this is your problem (from MySQL Reference Manual):
Quote:
After connecting to the server as root, you can add new accounts. The following statements use GRANT to set up four new accounts:

mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> WITH GRANT OPTION;
mysql> CREATE USER 'admin'@'localhost';
mysql> GRANT RELOAD,PROCESS ON *.* TO 'admin'@'localhost';
mysql> CREATE USER 'dummy'@'localhost';
The accounts created by these statements have the following properties:

Two of the accounts have a user name of monty and a password of some_pass. Both accounts are superuser accounts with full privileges to do anything. The 'monty'@'localhost' account can be used only when connecting from the local host. The 'monty'@'%' account uses the '%' wildcard for the host part, so it can be used to connect from any host.

It is necessary to have both accounts for monty to be able to connect from anywhere as monty. Without the localhost account, the anonymous-user account for localhost that is created by mysql_install_db would take precedence when monty connects from the local host. As a result, monty would be treated as an anonymous user. The reason for this is that the anonymous-user account has a more specific Host column value than the 'monty'@'%' account and thus comes earlier in the user table sort order. (user table sorting is discussed in Section 5.4.4, “Access Control, Stage 1: Connection Verification”.)
So create a user test@localhost with the same password to take precedence over the anonymous default user for localhost in MySQL and try again. Hope it helps.

Kind regards,

Eric
 
Old 04-13-2011, 08:12 AM   #5
Harry2o
LQ Newbie
 
Registered: Aug 2006
Posts: 12

Original Poster
Rep: Reputation: 0
Thanks, Eric, I think that was the problem (taking the user "Any" is the named anonymous).

Checking the machines where the creation of a new user was successful and usable didn't have that user "Any". I wonder why some machines (i.e. some installations of MySQL server) available to me do have that(those) user(s) (for different host origins) and others don't ...

However, I think that fixed the problem!
 
Old 04-13-2011, 08:36 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297Reputation: 1297
Hello,

Glad you got a solution and thanks for marking the thread solved. On a side note, the anonymous user gets created normally upon first run of the MySQL server (mysql_install_db) so maybe there's the difference. Check if you have different versions of MySQL server on your servers and check differences between that script on those different servers. Or maybe on the other servers someone executed mysql_secure_installation instead of mysql_install_db which deletes the default test database and anonymous user. That might shed some light. Have fun with Linux.

Kind regards,

Eric
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MYSQL: Access denied for user 'root'@'localhost' (using password: NO) jun_tuko Linux - Software 3 03-05-2013 06:37 AM
Changed my root user access for mysql access to Any from localhost SSBN Linux - Server 2 03-14-2011 02:25 PM
Mysql error 1045: Access denied for user 'root'@'localhost' (using password: YES) visitashu Linux - Server 15 11-10-2010 11:05 PM
mysql server ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using pas tarak420 Linux - Server 2 09-18-2008 09:52 PM
Sarge mysql-server Access denied for user: root@localhost infinity432 Linux - Software 2 05-18-2005 11:42 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 09:38 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration