Showing posts with label MySQL. Show all posts
Showing posts with label MySQL. Show all posts

Sunday, February 20, 2011

Installing Apache, MySQL and PHP in Linux-Ubuntu

Apache is the most commonly used web server. It is a free open source web server. PHP is an open source server scripting language. It has a lot of advantages. MySQL is also an open source database used for small and medium data storage. It can also used for large data storage also.

We can install apache, PHP and MySQL in two ways. 1. Download source code from their site and install. 2 the easiest way install it from synaptic package manager. If you use this method apt-get automatically manage all dependencies. So I explain the second method here.

1. Open the Terminal from Applications -> Accessories -> Terminal

2. Install apache2 copy paste command to terminal
sudo apt-get install apache2

3. Install PHP5
sudo apt-get install php5 libapache2-mod-php5

4. Restart apache
sudo /etc/init.d/apache2 restart

Now the PHP was installed. To test it create a php page in /var/www/ - the webroot and run it
Example sudo gedit /var/www/hello.php
write a basic php code in it

to run this script type http://localhost/hello.php in your browser and you can see "Hello World" in it.

5. Install mySQL
sudo apt-get install mysql-client mysql-server mysql-query-browser mysql-admin mysql-navigator php5-mysql php5-gd

6. Restart apache
sudo /etc/init.d/apache2 restart 

7. If you need phpmyadmin follow this step. If you like to use MySQL GUI then skip this step
sudo apt-get install phpmyadmin 

Restart apache
sudo /etc/init.d/apache2 restart 

Add following lines in httpd.conf
# Enable PHPMyAdmin
Include /etc/phpmyadmin/apache.conf

To access httpd.conf copy paste following line to terminal

sudo gedit /etc/apache2/httpd.conf

Restart apache
8. If you need to access your url as http://localhost/~username, enable userdir module in apache2. enable mod_rewrite to allow clean url
cd /etc/apache2/mods-enabled
sudo ln -s ../mods-available/userdir.load
sudo ln -s ../mods-available/userdir.conf
sudo ln -s ../mods-available/rewrite.load
sudo /etc/init.d/apache2 reload

9. Create folder /home/<username>/public_html -- > this is the folder which we are going to use as the document root for local development. So you will be accessing your local websites as http://localhost/~username/sitename

10. Edit /etc/apache2/mods-available/userdir.conf and change the AllowOverride line to just read AllowOverride All
Now you can use public_html as user document root

Enjoy scripting

Tuesday, February 15, 2011

Five steps to recover MySQL root password

MySQL is one of the most commonly used database. Most of the small and medium websites uses MySQL as the back end. It is the most popular open source database. The full privilege user account for MySQL is "root" user. This user account was configured at the time of installation. So some people facing issues to login to MySQL database because of forgetting root password. You can recover a MySQL database server password with the following five easy steps:

The commands explained here is for linux machines. First login to your system as the 'root' user.
Step 1: Stop the MySQL server process.
Open command prompt and type following command to stop MySQL server process.
# /etc/init.d/mysql stop
Output:
Stopping MySQL database server: mysqld.

Step 2: Start the MySQL (mysqld) server/daemon process with the --skip-grant-tables.
By using this option you can login to MySQL without password.

command used for login is
# mysqld_safe --skip-grant-tables &
Output:
[1] 2961
mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Step 3: Connect to the MySQL server as the root user.
Use MySQL client to connect. Now you can login to MySQL without password.
#mysql -u root

Output:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.49-1ubuntu8.1 (Ubuntu)

Step 4: Set a new root password.
You can set new password to root user now. Use following commands to set new password.
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;


Step 5: Restart MySQL server
First quit mysql and then restart the MySQL server by using following command
# /etc/init.d/mysql restart

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Maintained by Web Themes