$dbcnx = mysql_connect('localhost', 'root', 'rgehtyu'); does not work in my Linux.
We are making a Database-driven website using php and MySQL, this is for our degree project for the university. We are using the “Building a Database-Driven Web Site Using PHP and MySQL” from sitepoint.com as a guide and it has been very helpful.
In our development machine (in home) we have Windows 98 and Personal Web Server, in this environment everything is going right, but, in university’s machine we have Linux (redhat) and Apache, in that machine the PHP and MySql were already installed and We can’t reinstall it. The server name is Server1 or yyy.com.co.
We can use MySQL server all right from the emulator terminal, I mean, entering with mysql -u root -p and I can use the databases and select and update information. And I'm sure that PHP is working well because I have some php pages that don't interact with database and it work fine.
We are working the pages from a virtual host named server74 or xxx.com.co.
The problem is that using Linux we can’t connect to MYSQL server using PHP. In that case the system returns the following errors:
Returns the error:
“Warning: MySQL connection failed. Can’t connect to localhost MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (111) in www.xxx.com.co/xxx.php on line 47.
Returns the error: “Warning: MySQL connection failed. Host ‘server1.yyy.com.co’ is not allowed to connect to this MySQL server in www.xxx.com.co/xxx.php on line 47.
We think the problem is that MySQL server was installed with another server name and does not have registered server1 as a allowed server or something like that. But We didn’t find the file to define this.
I know that MySQL has multiple permissions. That is, each user can have permissions based on the machine name used to access the database (localhost is probably the most common one for PHP) as well as the particular database used.
The second error appears to be saying that your permissions are invalid from the other machine name.
The first error actually looks a lot like the error I get when the MySQL daemon is not running or accepting connections.
I don't know how to help you, because the issue appears to be out of your hands (the MySQL admin will have to adjust your permissions at least in the case of the second error you described).
When I look into the Linux file system I do so with the same degree of bewilderment as when I open the hood and peer into the engine bay of my Honda Civic. However, I did notice that the socket is being stored in /var/lib/mysql/mysql.sock whereas by default you would normally find it in /tmp/mysql.sock I would be getting onto the sysadmin for that box and seeing if they can help you iron out the connection issues. BTW, if I am not mistaken, PHP is configured by default to only connect to a local MySQL database. Or is it MySQL that by default will only allow local connections? Either way, I think there is some fiddling to do there too to change from the defaults.
Bookmarks