Ik gebruik overal mysqlhost in mijn PHP scripts omdat dit zo op mijn hosting moet. Nu wil ik mijn website lokaal op mijn Debian-servertje kunnen testen. Om mysqlhost thuis te kunnen gebruiken heb ik in mijn /etc/hosts volgende regel toegevoegd:
als ik nu ping naar mysqlhost, werkt dit perfect. Maar een connectie met mySQL werkt niet, terwijl dit met localhost wel gaat.
Hier een stukje uit mijn shell ter verduidelijking:
code:
1
| 127.0.0.1 mysqlhost |
als ik nu ping naar mysqlhost, werkt dit perfect. Maar een connectie met mySQL werkt niet, terwijl dit met localhost wel gaat.
Hier een stukje uit mijn shell ter verduidelijking:
code:
1
2
3
4
5
6
7
8
9
| debian:~# mysql --host=localhost -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 to server version: 3.23.49-log Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql> quit Bye |
code:
1
2
3
| debian:~# mysql --host=mysqlhost -p Enter password: ERROR 2003: Can't connect to MySQL server on 'mysqlhost' (111) |
code:
1
2
3
4
5
6
7
8
9
| debian:~# ping -c3 localhost PING debian (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.2 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.1 ms --- debian ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.1/0.1/0.2 ms |
code:
1
2
3
4
5
6
7
8
9
| debian:~# ping -c3 mysqlhost PING debian (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=255 time=0.3 ms 64 bytes from 127.0.0.1: icmp_seq=1 ttl=255 time=0.1 ms 64 bytes from 127.0.0.1: icmp_seq=2 ttl=255 time=0.1 ms --- debian ping statistics --- 3 packets transmitted, 3 packets received, 0% packet loss round-trip min/avg/max = 0.1/0.1/0.3 ms |