Search This Blog

Thursday, March 17, 2011

Allow remote access to apache on WAMP server on Windows; allow remote access to MySQL on WAMP server on Windows;

 

To allow remote access to apache on Windows change the file: c:\wamp\bin\apache\Apache2.2.17\conf\httpd.conf

You need to allow remote access to directory C:\wamp\www like this:

<Directory "c:/wamp/www/">
    ExecCGI MultiViews
    Options Indexes FollowSymLinks
    AllowOverride all

    Order allow,deny
    Allow from all

</Directory>

 

To grant remote access to MySQL:

use mysql;

GRANT ALL PRIVILEGES ON *.* to root@'%' IDENTIFIED BY 'sys';

flush privileges;

 

To see what is already allowed do this:

use mysql;

select user,host from user;

+------+-----------+
| user | host      |
+------+-----------+
| root |           |
| root | %         |
|        | localhost |
| root | localhost |
+------+-----------+
4 rows in set (0.00 sec)

“empty” places are nulls here. ‘%’ means from any host.

14 comments:

  1. To enable mysql remote access sometimes you need to edit the file:
    vi /etc/my.cnf
    comment the line "skip-networking"
    bind-address=YOUR-SERVER-IP

    On Archlinux you have to edit the file: /etc/hosts.allow
    as well. Add:
    mysqld : ALL : ALLOW
    mysqld-max : ALL : ALLOW

    ReplyDelete
  2. mysql -u root

    FLUSH PRIVILEGES;

    SET PASSWORD FOR root@'localhost' = PASSWORD('newpassword');

    UPDATE mysql.user SET Password=PASSWORD('newpassword') WHERE User='root';

    (remember to user '' instead of "")

    ReplyDelete
  3. i'm working with a wamp.. where should i make
    the changes to a file to allow the mysql?

    ReplyDelete
  4. MySQL 4.0 add user:

    use mysql;
    grant all on dbname to 'username'@'localhost' identified by 'yourpassword';

    ReplyDelete
  5. This command creates a user:

    CREATE USER 'jeffrey'@'localhost' IDENTIFIED BY 'mypass';

    ReplyDelete
  6. INSERT INTO user (Host,User,Password) VALUES('%','user','pass');
    UPDATE mysql.user SET Password=PASSWORD('pass') WHERE User='user';
    FLUSH PRIVILEGES;

    ReplyDelete
  7. Hi thanks a lot for the good info, but I also had to Port Forward to my Internal IP address the port 80 (the one Apache uses) through the router page, otherwise my friends couldn not enter my website app hosted from WAMP. Thanks!

    ReplyDelete
  8. Ah and just also to remind, that if you have done everything as said and working good, when you paste the public IP address on the browser url from the server machine, you might get redirected to the router page, which is fine and normal, most recent routers doesn't allow that, so don't go crazy as I went trying to figure out. It will work if you enter from a network different from the server machine. Cheers.

    ReplyDelete
  9. I created user user@'%'. But I can not connect with:
    mysql_connect('localhost:3306', 'user', 'password');

    When I created user user@'localhost', I was able to connect. Why? Doesn't '%' mean from ANY host?

    ReplyDelete
  10. thanks.. its nice demo

    ReplyDelete
  11. Nice description......... Thanks

    ReplyDelete

If you like this post, please leave a comment :)