TIPS &TRICKS

OpenSource For You - - Trips & Tricks -

Auto restart Apache af­ter every .conf file change

Shown be­low are the steps to auto restart Apache af­ter every change made to the .conf file.

If ‘in­cron’ is al­ready in­stalled in your sys­tem, then skip Steps 1 and 2.

$ sudo apt-get in­stall in­cron $ sudo nano /etc/in­cron.al­low

Add <USER­NAME> at the end of this file and save. $ sudo in­crontab -e

Once the in­crontab is open in ed­itable mode, add the fol­low­ing line at the end of the con­tent:

/etc/apache2/apache2.conf IN_MODIFY /usr/sbin/ser­vice apache2 restart

Save and exit the file.

From now on, every change in the /etc/apache2/ apache2.conf file will trig­ger /usr/sbin/ser­vice apache2 restart to restart the Apache server. You can also use in­cron to per­form other use­ful tasks.

—Swap­nil Sri­vas­tava, sri­vas­tava.swap­nil99@ gmail.com

Re­cov­er­ing the MySQL root pass­word

There are so many sit­u­a­tions in which you need to re­cover the root pass­word of your MySQL in­stal­la­tion. To re­cover the pass­word, first stop the MySQL ser­vice, as fol­lows:

# /etc/init.d/mysqld stop Add skip-grant-ta­bles by edit­ing the my.cnf file: # vim /etc/my.cnf

Af­ter open­ing the file in any text editor, add skip-grant­ta­bles un­der the [mysqld] sec­tion. Save and exit the file. Now you can start the MySQL ser­vice, as fol­lows:

# /etc/init.d/mysqld start

Next, you need to log into the MySQL server with­out any pass­word, as shown be­low:

# mysql

Use the fol­low­ing code to re­set the pass­word for the ‘root’ user:

mysql> use mysql mysql> UP­DATE user SET pass­word=PASS­WORD('new_­pass') where user='root';

For flush priv­i­leges, use the code shown be­low:

mysql> flush priv­i­leges; mysql> exit

Now, re­vert back to the pre­vi­ous state by stop­ping the MySQL ser­vice, as fol­lows:

# /etc/init.d/mysqld stop

Edit my.cnf and re­move skip-grant-ta­bles.

Af­ter sav­ing the my.cnf file, you can start the MySQL ser­vice:

# /etc/init.d/mysqld start

Now you can log in with the new pass­word, us­ing the fol­low­ing com­mand:

# mysql -u root -p new_­pass —Kishor Gavali, kishorgavali@gmail.com

Newspapers in English

Newspapers from India

© PressReader. All rights reserved.