SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jun 2001
    Location
    Bogotá, Colombia
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $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:

    If we use the connect sentence with ‘localhost’:

    $dbcnx = mysql_connect('localhost', 'root', 'rgehtyu');

    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.

    If we use the connect sentence with ‘server1’:

    $dbcnx = mysql_connect('server1', 'root', 'rgehtyu');

    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.

    We hope anyone of you could help us, thank you.

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2001
    Location
    Balto, MD
    Posts
    36
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Connect Errors

    There appear to be a few things going on here.

    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).

    Hope this helps.

    Jeff

  3. #3
    SitePoint Enthusiast
    Join Date
    Apr 2000
    Location
    Palo Alto, CA
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try to see what port MySQL listening to, 32768 default.
    then try
    $connection = mysql_connect("127.0.0.1:32768","root","<pass>");

    You can see open ports by typing:
    netstat -a
    and look for LISTEN type ports... you'll figure it.

  4. #4
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's MySQL that will by default not allow remote connections.
    Kevin

  6. #6
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanx tubedogg


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •