Saturday, April 25, 2009

PHP +MySQL + PHP My Admin

I had to install PHP, MySQL on my workstation recently, and although the steps are relatively simple, it took me quite sometime to configure everything.

The steps can be summarized as follows:

INSTALLING PHP + MySQL
sudo apt-get install mysql-server
sudo apt-get install apache2
sudo apt-get install php5
sudo apt-get install php5-mysql
sudo apt-get install phpmyadmin


CONFIGURING MySQL
sudo vim /etc/mysql/my.cnf

Find for 'bind-address' configuration:
bind-address

By default, it should be either localhost, or the loopback address (127.0.0.1)

change the value to be the IP address of your machine. (e.g. 192.168.0.10)
This tells MySQL server to listen to that address, instead of the loopback address.

RESTART MySQL
sudo /etc/init.d/mysql restart


CONFIGURE MySQL SECURITY
1. Login to phpmyadmin: http://localhost/phpmyadmin
2. Go to home
3. Create new database, say 'helloworld'
4. Go to home
5. Configure new user.
5.1 Go to 'user' table.
5.2 Click 'Insert'
5.3 Make sure that you specify % as the 'Host' value. This is saying that the user is given access from anywhere
6. Configure the user access for the database
6.1 Go to 'db' table
6.2 Click 'Insert'
6.3 Make sure that you specify % as both 'Host' and 'User' value. Also, use the database name for the 'Db' value (in our case, its 'helloworld'

You should now be able to connect to the database remotely, using tools such as DbVisualizer.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home