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 = 192.168.11.57
Workstation IP = 192.168.11.4

vi /etc/mysql/my.cnf

#bind-address           = 127.0.0.1
bind-address            = 192.168.11.57




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;

mysql> CREATE TABLE PHONES(
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@'192.168.11.4' IDENTIFIED BY 'your-root-password';
mysql> GRANT ALL ON *.* to root@'192.168.11.57' IDENTIFIED BY 'your-root-password';

mysql> FLUSH PRIVILEGES;




Update MySQL user password

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