Monday, April 01, 2013

Setup MySQL & PHP in Ubuntu

Setup MySQL & PHP in Ubuntu

Please make sure if your Apache & PHP was properly installed

Install the following packages.
apt-get install mysql-server
apt-get install libapache2-mod-auth-mysql
apt-get install php5-mysql

Restart Apache afterwards.

/etc/init.d/apache2 restart

Edit the MySQL config file, and make change as below. This example assumed you take IP as below.have
Apache/PHP/MySQL Server IP =
Workstation IP =

vi /etc/mysql/my.cnf

#bind-address           =
bind-address            =

Creat a Database & Grant privileges for user access. MySQL default password is blank.

$ mysql -u root -p
Enter password:
mysql> CREATE DATABASE mydb;

mysql> use mydb;

pid int(11) primary key auto_increment,
name varchar(100) not null,
price decimal(10,2) not null,
description text,
created_at timestamp default now(),
updated_at timestamp

mysql> use mysql

mysql> GRANT ALL ON *.* to root@'' IDENTIFIED BY 'your-root-password';
mysql> GRANT ALL ON *.* to root@'' IDENTIFIED BY 'your-root-password';


Update MySQL user password

# mysqladmin -u root -p'your-old-password' password 'your-old-password''