Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I ran this command-

[root@dev-img mysql]# mysql -u root -h 192.168.1.181 -e "use mysql;"

and this is the output I got-

ERROR 1045 (28000): Access denied for user 'root'@'192.168.1.65' (using password: NO)

Is there anything wrong with my command? I've searched everywhere and the syntax seems to be as above.

share|improve this question

migrated from stackoverflow.com Dec 12 '12 at 16:28

This question came from our site for professional and enthusiast programmers.

1  
Off-topic; belongs on Database Administrators –  Jim Garrison Dec 12 '12 at 5:08
    
I normally use ssh tunnels to access remote mysql databases. My platform is MacOSX. I use Sequel Pro to access mysql remote sites using a ssh connection. Restated ... I use public/private keys for ssh access to the machine and then access mysql databases 'locally'. –  kjtl Dec 12 '12 at 5:27
add comment

4 Answers 4

Two possible problems

  1. You didn't specify the -p option. Without -p the client will not prompt for a password and will attempt to connect without one
  2. The database may not be configured to allow remote login for root. You may have to login on the server and enable remote access (i.e. GRANT ALL ON *.* TO root@'%' IDENTIFIED BY '...';)
share|improve this answer
add comment

I will add though that allowing root from remote clients (especially allowing root from '%' ) is VERY BAD security wise

share|improve this answer
add comment

Extract:

How Do I Grant Access To An Existing Database?

Let us assume that you are always making connection from remote IP called 202.54.10.20 for database called webdb for user webadmin, To grant access to this IP address type the following command At mysql> prompt for existing database, enter:

mysql> update db set Host='202.54.10.20' where Db='webdb';
mysql> update user set Host='202.54.10.20' where user='webadmin';

Review complete info:

http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html

Aditional Info:

http://www.rackspace.com/knowledge_center/article/mysql-connect-to-your-database-remotely

Regards.

share|improve this answer
add comment

You need to make sure there exists a user root@192.168.1.65 with privileges to the database mysql.

If you have access to the mysql instance another way, do the following to see what privileges this user has:

show grants for root@'192.168.1.65';

The results should look something like the following:

grant all privileges on mysql.* to 'root'@'192.168.1.65' identified by password 'XXXX';

If you don't see results for that "show" statement above, then use the "grant" statement above to give the privileges.

If the IP address you are connecting from changes often, you can open it up to the wildcard host %, like:

grant all privileges on mysql.* to 'root'@'%' identified by password 'XXXX';

but that's not terribly secure.

(If you don't have access, ask your DBA/webhost to do that.)

Then you can connect using that statement, but add the -p flag so you can enter your password:

mysql -u root -p -h 192.168.1.181 -e "use mysql;"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.