Web Hosting Talk







View Full Version : ERROR 1045: Access denied for user: 'root@localhost'


andy18
08-15-2003, 12:57 PM
Hi guys,

When I type mysql on the shell as root , I am getting the error "1045: Access denied for user: 'root@localhost' (Using password: YES) "

I have tried the above steps by restarting the mysql with the --skip-grant-tables access :

root@abc [/var/lib/mysql/mysql]# /etc/rc.d/init.d/mysql start --skip-grant-tables;

root@abc [/var/lib/mysql/mysql]# mysql -u root
ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)

I have checked the /.my.cnf file and the file is on the root folder.

Any advice will be appreciate .

tracphil
08-15-2003, 01:18 PM
You probably have tried this but.. try logging into as root with out a password.

If you are using a password, are you aware that root for mysql and root for unix are two different roots..

You may want to do: mysql -uroot -p and hit enter.

root on!

This are simple I know but just wanted to make sure you hit the basics

andy18
08-15-2003, 01:20 PM
Hi ,

Thanks for the advise...

Tried login without password , below are the output :

root@abc [/var/lib/mysql/mysql]# mysql -u root -p
Enter password:
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

smartbackups
08-15-2003, 01:21 PM
you will need to log in with a password, one is set even by default.

mysql -u root -p

tracphil
08-15-2003, 01:22 PM
MySQL is not set with a password by default.

tracphil
08-15-2003, 01:24 PM
Try logging in from a remote host: mysql -h hostname -uroot -p

andy18
08-15-2003, 01:27 PM
Hi Weberz,

Same error :(

smartbackups
08-15-2003, 01:30 PM
reinstall mysql?

Is this redhat? Is this a mysql rpm installation or did you build it yourself?

andy18
08-15-2003, 01:34 PM
Hi,

We are using Cpanel and the MYSQL is installed when installing the control panel.I tried run the /scripts/easyapache but that does not help...

It is strange as the MYSQL server is still working before and we just noticed this when we try to login to perform some stuff on the server.

User's database is not working as well...:(

Could it be that the root permission is not in the MYSQL tables and caused the error?

If I reinstall the MYSQL , will all the MYSQL db on the server be wiped out??:confused:


Thanks !!!

tracphil
08-15-2003, 01:45 PM
reset mysql's root password from within WHM.

andy18
08-15-2003, 01:47 PM
Hi,

Waiting for mysql to restart.....030815 22:38:18 Can't start server: Bind on TCP/IP port: Address already in use
030815 22:38:18 Do you already have another mysqld server running on port: 3306 ?
030815 22:38:18 Aborting

030815 22:38:18 /usr/sbin/mysqld: Shutdown Complete

Done
Changing Password....ERROR 1045: Access denied for user: 'root@localhost' (Using password: YES)
/usr/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: YES)'
Done
Reloading Mysqld...
Done
Attempting to restart mysql

Waiting for mysql to restart....
.
.
.
.
.
.
.
.
.
.
finished.

I have tried check the password in the .my.cnf file and the password did updated.


Thanks !!!

SPaReK
08-15-2003, 04:08 PM
Log into your shell, su to root or somehow get a root prompt. edit the file:


/etc/rc.d/init.d/mysql


look for a line:


$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file


change it to read:


$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file --skip-grant-tables


then stop and start mysql:


/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysql start


now type:


mysql mysql


type:


update user set password=password('<your root password>') where user="root";


Change <your root password> to whatever password is set in your /root/.my.cnf file. This should be the same password you specified in your WHM.

type 'exit' to return to the shell prompt.

undo the changes you made to /etc/rc.d/init.d/mysql so that it appears as it did before:


$bindir/mysqld_safe --datadir=$datadir --pid-file=$pid_file


stop and start mysql again:


/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysql start


you should now be able to access your mysql databases by just typing


mysql


as the mysql client will read ~/.my.cnf for username and password information. Otherwise you may have to use the -u and -p option to pass a username and password.

Hope this helps.

andy18
08-15-2003, 05:03 PM
Hi SPaReK,

Amazing...that really help...it fixed the issue...thanks !!!

but I was wondering why typing only mysql will not work anymore as in the past when we type mysql only we will be login to the mysql server.From now on , we will have to type the mysql -u root -p.....

is there a fix for this?


Thanks again for everyone who help out !!

WII-Aaron
08-16-2003, 11:44 AM
Hi,

I'm having this same problem. The fix above didn't work for me. Any other suggestions?

Aaron

SPaReK
08-17-2003, 01:37 AM
Do you have a .my.cnf file in your root home directory? You will have to be root in order for the mysql client to read that file. The permissions on it should be 700.

andy18
08-17-2003, 05:59 PM
Hi,

Found the cause of the problem !We have included "Special Character ( &%#@ ) "in our MYSQL root password and this had caused the problem . We reset the password without any Special character and it resolved the issue. Thank God !:stickout:

Steps :

Make sure root pass is in /root/.my.cnf
This is usually the first root pass the box was given once cpanel is installed.
If it still does not work, you will need to reset the mysqld root pass.
First, stop the mysqld, usually /etc/rc.d/init.d/mysql stop
Then stop chkservd to keep it from interfering with mysqld while you work on it with /etc/rc.d/init.d/chkservd stop
Start up mysqld , but, without the grant tables,
mysqld --skip-grant-tables -u mysql &
Then change the pass..

mysql -u root mysql UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
FLUSH PRIVILEGES;
Now you just killall -9 mysqld and start it up normally with it's safe_mysqld script..

and update your password in /root/.my.cnf

Remember NOT to include "Special Character" in the password !

Hope this help !

chanch
12-13-2004, 04:01 AM
Hello,
When I try,

# mysql

I get the following error

ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)

Can anyone help???

Angelo
12-13-2004, 07:19 AM
Try logging in with
# mysql -u root -p

If your password does not work, try to reset it.