Pages

Wednesday, October 30, 2013

Using mysqldump - How to back up a MySQL database on Linux with the mysql dump command


You do not need to invoke the mysql command or log into your MySQL server..
From your linux shell command line type:

MyLinuxServer:/ # mysqldump -u root -p  databaseName > databaseBackupFileName.sql;

You will be prompted to enter the password next "Enter password:"

View all MySQL databases - SQL command to show databases on MySQL Linux

Once you log into MySql,

mysql> SHOW DATABASES;

Log into a MySQL server

Command:

MyLinuxServer:/ # mysql -u root -p


You will be prompted to enter the password "Enter password:"  next



Tuesday, October 22, 2013

Stop, Start, Restart, Status of MySQL server



I've tired many commands, I find these to work the best using the Sys-V init scripts located in /etc/init.d.

Start:
sudo /etc/init.d/mysql start
Stop:
sudo /etc/init.d/mysql stop
Restart / reload configs:
sudo /etc/init.d/mysql restart
Check run status:
sudo /etc/init.d/mysql status

Wednesday, May 1, 2013

Find and sort all files by size, save results to a text file on a Linux system

Find and order all files by size, save the result to a text file on a Linux system

du -k | sort -nr | awk '
     BEGIN {
        split("KB,MB,GB,TB", Units, ",");
     }
     {
        u = 1;
        while ($1 >= 1024) {
           $1 = $1 / 1024;
           u += 1
        }
        $1 = sprintf("%.1f %s", $1, Units[u]);
        print $0;
     }
    ' > result_list_ordered.txt




Find files by modification date, within a modified by date range on Linux

Find files modified within a date range


Use these commands

touch --date "2013-04-29" /tmp/start
touch --date "2013-05-1" /tmp/end
find -type f -newer /tmp/start -not -newer /tmp/end

Search or find all users on a Linux system

List all users on a Linux OS

Try one of these:

# cut -d: -f1 /etc/passwd
# cat /etc/passwd | cut -d ":" -f1

Got other ideas on how to do this? please leave a comment

Thanks!