LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   mysql - can't access mysql database as root (http://www.linuxquestions.org/questions/linux-software-2/mysql-cant-access-mysql-database-as-root-514136/)

yogaboy 12-27-2006 05:12 PM

mysql - can't access mysql database as root
 
Hi,

Does anyone know which file holds the mysql database? I've got the error
mysql> use mysql;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'mysql'

and all the different "fixes" I've tried have failed. I'd like to replace the current file with an original. I just need the filename.


Your help is much appreciated.

jstephens84 12-27-2006 05:28 PM

Have you tried to give root All Privileges.
Code:

GRANT ALL PRIVILEGES on *.* to 'root'@'localhost

yogaboy 12-27-2006 08:07 PM

thanks for the reply. I tried that and a lot of other things, none of them worked. In the end I removed the /var/lib/mysql/mysql/user.* files and ran /usr/bin/mysql_install_db and now I can get in.

No use if you've already got a bunch of users, but sorted out my problem.

jstephens84 12-28-2006 04:34 AM

Quote:

Originally Posted by yogaboy
thanks for the reply. I tried that and a lot of other things, none of them worked. In the end I removed the /var/lib/mysql/mysql/user.* files and ran /usr/bin/mysql_install_db and now I can get in.

No use if you've already got a bunch of users, but sorted out my problem.

That will get you every time. The first time I have dealt with mysql I couldn't figure out why I was getting the same problem. But mysql_install_db sets up all the initial rights and gives the root account grant permissions on the user table under the mysql database.

One last thing. If you plan to administer you mysql db from a remote connection you might want to run
Code:

Grant ALL Privileges on *.* to 'root'@'%'

jschiwal 12-28-2006 04:41 AM

Mysql installs a manual in /usr/share/doc/packages/mysql. There is a section on securing it. The default config has a couple tables where root has full privileges with no password.

yogaboy 12-28-2006 06:58 AM

thanks for the help. Every time I've ever had to use mysql something has gone wrong at the setup stage, on whatever platform. You could say it was me :) but I've been using the mysql manual or other people's instructions... personally, I think the setup is crap. It's insecure by default, and there's enough people out there posting with similar problems to make me think they ought to do something about it.

I'll be using Postgres next time - for all the extra work I at least want a real database - and if anyone says I have to use mysql then they can do it themselves!


All times are GMT -5. The time now is 12:33 PM.