Steps to follow for query tuning

Few steps for query tuning.

1)  Check for if any sub query or exists or not exists is there if yes then try to change it in the joins .

2)  Try to check the way joins had been written try to put it in format to follow one to many relation ship and joins are in primary to foreign keys.

3)  if dead locks are happening due try to implement the serialization or try to use hint with (nolock) with select statement and with (rowlock) with insert update and delete statement.

There are many more way to do.

File system and mysql backup on shared hosting

Create two php files and upload to server. Following script will compress your files and able to take mysql backup in gzip format.

Before this create phpinfo.php file and add following code.

<?php

phpinfo();

?>

gzipfile.php
<?php
$Command = 'tar -czf /public_html/content/html/website.tgz /public_html/content/html';
exec($Command, $output, $result);
if($result > 0) {
echo 'Command not executed. ';
echo 'Error Details:'.$output;
} else {
echo 'Command executed sucesfully.';
}
?>

create mysqlbackup.php  file and add following lines.

<?php
$Command = 'mysqldump -udbusername -pdbpassword -hyour_database_hostname DBname | gzip > DBname.gz';

exec($Command, $output, $result);
if($result > 0) {
echo 'Command not executed. ';
echo 'Error Details:'.$output;
} else {
echo 'Command executed sucesfully.';
}
?>

 

Install Drupal using Drush command only

For setup the empty drupal project setup use following command

#drush dl drupal-7
Project drupal (7.28) downloaded to /home/manish/drupal-7.28.                                                                                                       [success]
Project drupal contains:                                                                                                                                           [success]
– 3 profiles: testing, minimal, standard
– 4 themes: stark, seven, bartik, garland
– 47 modules: drupal_system_listing_incompatible_test, drupal_system_listing_compatible_test, poll, rdf, statistics, user, taxonomy, translation, tracker, node,
contact, syslog, contextual, profile, overlay, forum, blog, book, system, aggregator, path, comment, help, simpletest, trigger, menu, dashboard, search, locale,
field_ui, shortcut, options, number, field_sql_storage, text, list, field, php, color, toolbar, filter, update, dblog, file, block, image, openid

#cd drupal-7.28

#drush site-install standard –account-name=admin –account-pass=admin –db-url=mysql://mydbusername:’pass@123’@localhost/mydbname

You are about to create a sites/default/files directory and create a sites/default/settings.php file and DROP all tables in your ‘marketplace’ database. Do you want to continue? (y/n): y
Warning: Using a password on the command line interface can be insecure.
ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1
Starting Drupal installation. This takes a few seconds …                                                                                                         [ok]
Installation complete.  User name: admin  User password: admin

after this you can check project in browser.

http://localhost/drupal-7.28

Redirect all traffic to HTTPS on your Drupal site

Your Drupal .HTACCESS file should now have a section that looks similar to this : – # Various rewrite rules. <IfModule mod_rewrite.c>   RewriteEngine on # Set “protossl” to “s” if we were accessed via https://.  This is used later # if you enable “www.” stripping or enforcement, in order to ensure that # you don’t bounce between http and https.   RewriteRule ^ – [E=protossl]   RewriteCond %{HTTPS} on   RewriteRule ^ – [E=protossl:s]

Install Postgresql On Ubuntu

Start with Installing PostgreSql
sudo apt-get install postgresql postgresql-contrib

next to do : Login with admin user    sudo -u postgres psql

\du : to check user available in postgressql

Than change the user Password with Alter user commend .

ALTER USER postgres WITH PASSWORD ‘newpassword’;
you can add new user with commend :
createuser [connection-option…] [option…] [username]
Like wise you can add user and change there attributes and Password too.
To exit form PostgresSQL use this commend  postgres=#\q ;

MySQL command prompt auto-complete

It’s Good Trick

Naveen S Nayak's Blog

If you work on the mysql command line, its nice to have an autocomplete similar to the linux bash where you press the TAB key and the commands complete.

In mysql, we can set it up to a degree to provide some hints when we type. Though it might not complete everything you type, it does complete table names etc.

2 ways to do it ( I am on CentOS 6.5 )

when you log into mysql, use the auto-rehash config option like

mysql --auto-rehash -u root -p

if this does not work, then try creating a file called .my.cnf in your home directory and put the below into it

[mysql]
auto-rehash

View original post