LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Mysql error 1045: Access denied for user 'root'@'localhost' (using password: YES) (http://www.linuxquestions.org/questions/linux-server-73/mysql-error-1045-access-denied-for-user-root%40localhost-using-password-yes-842880/)

visitashu 11-07-2010 12:47 PM

Mysql error 1045: Access denied for user 'root'@'localhost' (using password: YES)
 
Hi,
I was setting up mysql server on my box running Fedora Core 13.
Please see the version below -
" mysql Ver 14.14 Distrib 5.1.51, for redhat-linux-gnu (i386) using readline 5.1 "
I ran /usr/bin/mysql_secure_installation for some configurations
Gave root password, restarted mysqld service and did this -
$ mysql -u root -p
It allowed me to log in.
Then I imported a test.sql db. Rebooted the box.
Now when I tried to login to mysql -
I get the following error even after keying in the correct password.

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

I have not installed phpmyadmin yet.
I went through MySql forums, didn't find any valuable post
which could solve this. Some said to re-install Mysql,
I did so, it worked perfectly until box was rebooted.
Same error promts when I login next time.

It would be a great if anyone in this forum can support me here.
It has become a blocker for my development work as well.

Many thanks,

honeybadger 11-07-2010 01:11 PM

Hi, a very basic question.... are you able to log in as a normal user. If you can do that then try to run su or sudo and become root.
Hope this helps.

Flyte 11-07-2010 06:07 PM

Looks like SilverBack got the wrong end of the stick there. The OP said he couldn't log into mysql, not into a console.

Try this http://dev.mysql.com/doc/refman/5.0/...rmissions.html

Not sure why it'd change the root password when you reboot though.

visitashu 11-08-2010 01:27 AM

@SilverBack
I am not able to get the mysql> promt in both ways -as 'normal' or 'su -'

@Flyte
I did visit that link earlier, it couldn't change mysql password.
Or if it would have changed it is not allowing me in with new password.

When I remove /var/lib/mysql directory and re-install mysql. it works!

I am able to login to mysql, change DB and say >grant all privileges on DB.* to user@localhost identified by pswd;
I get encounter new error -
"ERROR 1133 (42000): Can't find any matching row in the user table"
When I exit out of mysql> and try logging in it doesn't allow. (Error 1045)

linuxlover.chaitanya 11-08-2010 01:40 AM

Are you sure you have a password set for the user? If not then try logging without the -p switch and see if you can log into mysql.

honeybadger 11-08-2010 03:01 AM

@Chaitanya ---- you got it right mate. I did not know what I was thinking (ssh perhaps). Thanks for pointing the error.

linuxlover.chaitanya 11-08-2010 03:52 AM

@Silver:
Yeah monday is anyhow an awful way to spend 1/7th of week. let monday go and you will be back in your senses. Diwali fervour has not sunk in yet with me as well. ;)

visitashu 11-08-2010 05:56 AM

Quote:

Originally Posted by linuxlover.chaitanya (Post 4152359)
Are you sure you have a password set for the user? If not then try logging without the -p switch and see if you can log into mysql.

Yes I have the password set for 'root' user. I run /usr/bin/mysql_secure_installation to do so.
Any more pointers ?

Thanks,

linuxlover.chaitanya 11-08-2010 06:01 AM

Okay you rebooted the server. Are you sure the service is running? What does this give you:
Code:

/etc/init.d/mysqld status
or
service mysqld status


visitashu 11-08-2010 10:00 AM

@Chaitanya

After rebooting my box ; /etc/init.d/mysqld says..service is running.
I do check mysqld.pid under /var/run/mysqld/ directory.
I tried killing it and restarting service ; service restarts but my login
issue is not resolved.

Thanks,

linuxlover.chaitanya 11-09-2010 12:23 AM

You said you imported some sql script? What script was it? Or was it for creating the database? Do you have by chance, any other user created on mysql with super privileges?

visitashu 11-09-2010 01:07 AM

That was a testdb.sql file which contains some tables / data.
I said : $ mysql -u root -p < testdb.sql
No, I do not have any other user.

Quote:

Originally Posted by linuxlover.chaitanya (Post 4153243)
You said you imported some sql script? What script was it? Or was it for creating the database? Do you have by chance, any other user created on mysql with super privileges?


linuxlover.chaitanya 11-09-2010 02:37 AM

Are you sure that sql import did not affect this all? Can you see what that sql script contains?

enine 11-09-2010 10:38 PM

Same issue here but on slackware. I found this guide http://www.basicconfig.com/linuxserv...ysql_slackware

can sign in fine as root but denied access to do anything.

visitashu 11-10-2010 11:37 AM

Quote:

Originally Posted by linuxlover.chaitanya (Post 4153303)
Are you sure that sql import did not affect this all? Can you see what that sql script contains?

No, I do not think so that sql import has caused any issue. When I re-installed Fedora for third time, I tried with empty .sql file
$ echo "" > blank.sql
$ mysql -u root -p < blank.sql

This got imported and when I logged in to mysql> and logged out of mysql>
I was unable to login for the next time.

But, again as per you said, let me go through main DB .sql file and grep for "user". If this returns something unexpected. I think we are close to results then.

Thanks,


All times are GMT -5. The time now is 08:24 AM.