0
votes

Hi I have a site develop in cakephp. I want to connect my cakephp to a database with an ip because me and my friends working together into the same network My ip is:192.168.0.3 Ip of database into the second pc: 192.168.0.4

I can ping 192.168.0.4 Into the second pc running xampp mysql into the system.

This is my database configuration:

public $default = array (
        'datasource' => 'Database/Mysql',
        'persistent' => false,
        'host' => '192.168.0.4',
        'login' => 'login',
        'password' => 'password',
        'database' => 'database',
        'prefix' => ''
    );

But gives me an error: Error: SQLSTATE[HY000] [2003] Can't connect to MySQL server on '192.168.0.4' (10061) requires a database connection ANd into the second pc this error: SQLSTATE[HY000] [2013] Lost connection to MySQL server at 'reading initial communication packet', system error: 61 requires a database connection

Pc1 and pc2 doesn't work but, if pc2 (where is located database) write into database config into the host: localhost, it works. Me not. How can I solve that?

2
can you connect with the mysql command line or any other client? Is you database configured at a standard port? have you tried using 'host' => '192.168.0.4:port'? - petervaz
no nothing SQLSTATE[HY000] [2005] Unknown MySQL server host '192.168.0.4:3306' (11004) requires a database connection - user1427811

2 Answers

0
votes

Check your MySQL config file (/etc/mysql/my.cnf) for the skip-networking option, which is enabled by default. Comment it out and restart MySQL.

0
votes

If you are using xampp on Windows, then you can resolve it by editing file your-xampppath\apache\conf\extra\httpd-xampp.conf

and find the below tag

# Close XAMPP sites here
<LocationMatch "^/(?i:(?:xampp|licenses|phpmyadmin|webalizer|server-status|server-info))">
    Order deny,allow
    Deny from all
    Allow from ::1 127.0.0.0/8 
    ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var
</LocationMatch>

and add

"Allow from all"

after Allow from ::1 127.0.0.0/8 {line}

restart xampp and you are done !!!!