Results 1 to 5 of 5

Thread: MySQL: connection problem of socket

  1. #1
    Join Date
    Nov 2008
    Posts
    1,259

    MySQL: connection problem of socket

    I work on MAC OS. I try to connect to the database (mysql) to save data

    Code:
    mysqli_connect('localhost','root','','base_gives')
    but I get the error below:

    Warning: mysqli_connect() [FUNCTION.mysqli-connect]: (HY000/2002): Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (2)
    When I connect to the local IP address, I can not find the web page saying that the apache server works

    Anyone any idea?

  2. #2
    Join Date
    Feb 2008
    Posts
    194

    Re: MySQL: connection problem of socket

    If you are with MAMP, by default it is apache and mysql on non standard ports (8888 and 8889 type).

    So either you tell him to connect on standard ports (80 and 3036, is a specific button), or you clear the port XXXX at the connection.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,259

    Re: MySQL: connection problem of socket

    I uninstalled MAMP and now I do a pure terminal. Maybe uninstall MAMP changed something at that level

    It seems to be a problem of location of the socket but I have yet defined in php.ini

    Code:
    mysql.default_socket = /tmp/mysql.sock

  4. #4
    Join Date
    Feb 2008
    Posts
    194

    Re: MySQL: connection problem of socket

    MAMP terminal is not in mac.

    If you do a php-i you will normally it does not use any php.ini. So we need to specify the address that you have modified (-c I think, do -- help for all this). Or touching the environment variables but I know nothing on Mac.

    And if you do I imagine that the terminal you started the MySQL server, we agree?

  5. #5
    Join Date
    Nov 2008
    Posts
    1,259

    Re: MySQL: connection problem of socket

    I think I just found the solution

    I put this config in the 'php.ini'
    Code:
    mysqli.default_socket =/tmp/mysql.sock
    address of the socket! And it works after apache restart!

Similar Threads

  1. How to allow remote connection to MySQL
    By Gomeler in forum Software Development
    Replies: 5
    Last Post: 17-12-2009, 01:24 PM
  2. Replies: 3
    Last Post: 07-11-2009, 09:36 PM
  3. connection problem with MySql
    By Gefry in forum Software Development
    Replies: 1
    Last Post: 30-04-2009, 10:52 AM
  4. Mysql connection with java
    By Xena in forum Software Development
    Replies: 2
    Last Post: 24-04-2009, 03:16 PM
  5. bad mySQL connection
    By Ron1 in forum Software Development
    Replies: 3
    Last Post: 12-02-2009, 12:37 PM

Tags for this Thread

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
  •  
Page generated in 1,714,003,954.16160 seconds with 17 queries