Hello I am on a Centos VPS with nginx + mysql + php-fpm installed. I am trying to allow remote access to a database on this machine from another of my VPS.

I tried out the following steps.

  • Modified the /etc/my.cnf file and then within the [mysqld] block added the lines bind-address = *
  • Saved and restarted the mysql service using the command /etc/init.d/mysqld restart
  • Logged into mysql and created an user by the name remote and password say pass
  • Typed the 'use social' command and tried to run the command GRANT ALL PRIVILEGES ON *.* TO remote@'' IDENTIFIED BY 'pass'; Where is the IP of the VPS I want to remote access the social database from.

The error is get is

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

Can someone let me know why I am encountering this error when I can log in and create users even operate on the database using the same username, root and the same password even after this error!!

  • 1
    What is the exact command you are issuing to get the above error ? – Iain Dec 30 '13 at 8:33
  • Can you start mysql client as root? mysql -u root -ppasswd? – Kondybas Dec 30 '13 at 9:14
  • yes i can start mysql client using 'mysql -u root -p` – Rick Roy Dec 30 '13 at 9:53
  • the exact command used was GRANT ALL PRIVILEGES ON *.* TO remote@'' IDENTIFIED BY 'pass'; The only difference is the IP and the password I am a bit worried about having to produce the IP and password in an open forum – Rick Roy Dec 30 '13 at 9:55
  • @RickRoy: You get that error message when you run the grant command ? – Iain Dec 30 '13 at 10:03

With this command you are creating an other root user


because you are given all privileges on mysql db too

GRANT ALL PRIVILEGES ON socialdb.* TO remote@'' IDENTIFIED BY 'pass';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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