Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>MySQL privileges are often granted per user <em>and</em> per IP address of the client host (client from the perspective of the database is the host where your PHP app is running).</p> <p>Your wi-fi router is probably allocating the IP address for your laptop with DHCP, so there's no guarantee that it will grant the <em>same</em> address to your laptop each time it renews the connection.</p> <p>I see two possible remedies:</p> <ol> <li><p>Some routers allow you to tie a specific IP address to a given MAC address so one PC will get the same IP address reliably (this is what I do on my home network).</p></li> <li><p>Or you can open privileges on your database server with a <a href="http://dev.mysql.com/doc/refman/5.1/en/grant.html" rel="nofollow noreferrer"><code>GRANT</code></a> statement so that any IP address within the range of DHCP addresses served by your router can access the database. Example:</p> <pre><code>GRANT ALL ON test.* TO 'databaseuser'@'192.168.1.%' IDENTIFIED BY 'databasepassword'; </code></pre> <p>You <strong>don't</strong> want to grant open access to <em>any</em> IP address, however, because then anyone on the broader network can potentially contact your database server. </p></li> </ol> <hr> <p><strong>update:</strong> Of course 192.168.1.% is an internal subnet that you'd use behind a firewall. That's just an example, showing that you can use wildcards for any octet in the address you give in your <code>GRANT</code> statement. </p> <p>If you are connecting from home, you probably have a single <strong>external IP address</strong> that your internet provider assigns, but this may change frequently, subject to their network management policies. You might have an option to get a static IP address that is guaranteed not to change, but this generally costs more.</p> <p>Of course if you are connecting from a coffee shop or an airport or whatever, your connection would appear as <em>their</em> external IP address.</p> <p>It would be most flexible of course to open up your MySQL privileges so that any client from any IP address could connect (assuming they know the username &amp; password). But the problem with that plan is that <em>any client from any IP address could connect</em> -- i.e. even when it's not you.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload