gnznroses Posted January 20, 2010 Share Posted January 20, 2010 I have two webservers. One has my database and I want to connect to tht database from the other server (using a PHP script). I've taken a PHP script that works perfect on the server that contains my DB and moved it to the new server, changing "localhost" to the DB server's IP (or domain - I tried both). I used cPanel to add my new server's IPs to the allowed hosts. I then tried changing host to %. When I try to connect and run a query - using PHP- I'm getting the error "no database selected". This is what I get from SSH (sanitized of course): mysql -u MYUSERNAME -p -h 67.164.XXX.XXX (it then asks for my password, which i enter) mysql> use DATABASENAME; > ERROR 1044 (42000): Access denied for user 'MYUSERNAME'@'%' to database 'DATABASENAME' (or before I changed host to % and just listed the other server's IP, it would say Access denied for user 'MYUSERNAME'@'123.123.XXX.XXX') If I SSH into the DB server I can select the DB no problem. I checked that the mysql user has valid permissions. And well, this is where it gets odd. The only user with ANY permissions is 'root'. The username I am using has all of their permissions as 'N'. But, I never connect to mysql via root. On the server with the DB, I always use that same username ("MYUSERNAME") and have no issues. I tried though changing Select_priv to Y and it still did not work. Lastly, I checked my my.cnf file to be sure skip-networking is not there. And I did restart MySQL service after making changes. Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/189116-remote-connection-problem/ Share on other sites More sharing options...
fenway Posted January 20, 2010 Share Posted January 20, 2010 use SHOW GRANTS to find out what grants that user actually has. Quote Link to comment https://forums.phpfreaks.com/topic/189116-remote-connection-problem/#findComment-998456 Share on other sites More sharing options...
gnznroses Posted January 20, 2010 Author Share Posted January 20, 2010 wow, ok oddly enough everything works fine now. i ran use DBNAME; and it changed it. and the php script works. i haven't changed a thing since i wrote this thread. so strange. Quote Link to comment https://forums.phpfreaks.com/topic/189116-remote-connection-problem/#findComment-998464 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.