fbpx

MySql backup & restore commands

This article has some handy commands to backup and restore mysql databases. Some of the terms used below refer to USERNAME = your username MYSQL_PASSWORD = your password DATABASE_1 = name of the database LOCAL_DOMAIN.COM = local domain name DESTINATION_DOMAIN.COM = remote domain name Take MySql dump, gzip it and take it in a directory. mysqldump...

Read more...

MySql monitoring & optimzing commands

Some of the terms used in the article below refer to USERNAME = your username MYSQL_PASSWORD = your password DATABASE_1 = name of the database LOCAL_DOMAIN.COM = local domain name DESTINATION_DOMAIN.COM = remote domain name Restart MySql Server sudo service mysql restart Check database size mysql> SELECT CONCAT(sum(ROUND(((DATA_LENGTH + INDEX_LENGTH - DATA_FREE) / 1024 / 1024),2))," MB") AS...

Read more...

Server Monitoring Commands

Disk Stats Disk Usage detials df -h LSOF means list of open files. This command watches total open files on server. A very good article for further reading http://www.catonmat.net/blog/unix-utilities-lsof/ watch --interval=1 --differences "lsof | wc -l" Disk IO Stats iotop sar disk io stats sar -s 15:00:00 -e 17:00:00 shows the disk I/O stats watch --interval=1 iostat http://www.tecmint.com/how-to-check-disk-space-in-linux/ General Monitoring Find Out...

Read more...

Convert MySql database tables types from MyISAM to InnoDB

Conversion on dump file If you have a dump file of mysql, The easiest way is to run the command on the dump file. It will replace the tables from MyISAM to INNODB sed -i 's/MyISAM/INNODB/g' dbname.sql You can also change the command and convert INNODB to MyISAM by this command sed -i 's/INNODB/MyISAM/g' dbname.sql     Conversion on current...

Read more...

How To Create a SSL Certificate on Apache for Ubuntu 14.04

TLS, or transport layer security, and its predecessor SSL, secure sockets layer, are secure protocols created in order to place normal traffic in a protected, encrypted wrapper. In this guide, i will cover how to create a self-signed SSL certificate for Apache on an Ubuntu 14.04 server, which will allow...

Read more...

Copy MySql specific table rows to another table

The safest way to do it is to fully specify the columns both for insertion and extraction.  You can copy the schema of the table by this command. CREATE TABLE new_table LIKE old_table; You can disable index building in start and enable indexes in end. This will speed up the process in...

Read more...

How to write your first shell script

Launch a terminal vi, nano or any other prefered editor of your choice. I will be using nano as a editor. nano /home/bash-scripts/my-first-script.sh At the top type the following code #!/bin/bash. This is known as a Shebang line. #!/bin/bash echo "start of script" ls echo "end of script" This script prints a header line then list...

Read more...

Find files on linux and move them to a temporary directory

These are the commands to search and move data on linux -iname - File name search pattern (case insensitive) Move .mp3 files and not directories, use: find / -iname "*.mp3" -type f -exec /bin/mv {} /mnt/mp3 \; Find all directories having name mp3 and move: # find / -iname "*.mp3" -type d -exec /bin/mv...

Read more...

MySql handy commands

Replace field data with another value UPDATE table_name SET field = replace(field,'string-to-find','string-that-will-replace-it');    

Read more...