How to migrate a MySQL database from one Linux server to another using the command the line

How to move/migrate a MySQL database from one Linux server to another via the command line using “mysqldump” to export the database , “scp” (secure copy) to transfer it, and “mysql” to import it.

In this example, we’ll migrate/move a theoretical SQL database named twatdb from it’s current location on example.com over to the twat.ca server.

1. Export the database from the old server using “mysqldump”

For our example, let’s say our database is named “junglist”. Before transferring the database file to the new VPS, we first need to create a database dump on the original server using mysqldump:

mysqldump -u root -p –opt [database name] > [database file].sql

2. Transfer the .sql database file to the new server

While there’s many different ways we could move our .sql file over to the new server (SFTP, rsync, etc.) we’re going to use “scp” (secure copy) in this example.

Syntax: scp [database name].sql [username]@[servername]:path/to/database/

Using scp, we’ll put the file in our home folder on the new server:

3. Import the database on the new server

Log in to your new server via SSH and import using mysql:

mysql -u root -p [database name] < [database file].sql

How to check your connection speed with Speedtest.net from Ubuntu/Debian command line

How to check your internet connection speed using the “speedtest-cli” Python application for Ubuntu & Debian and optionally share your results.

1. Install speedtest-cli application

Note: You can optionally skip the “sudo” prefixes on the commands below by switching to root using the sudo su command.

First, make sure your list of repository packages is up to date:

Next, install the Python package manager (pip):

Now install the speed-cli application using Python package manager (pip):

And if you ever want to upgrade the application, you can use:

2. Test your connection speed using speedtest-cli application

To check your internet connection speed, run the speedtest-cli application:

Alternatively, if you want to be able to share your results:

Run the speedtest-cli application using the optional share argument:

Paste the address above into a browser to see the result. Example:

6017542333.png Speedtest.net result

For additional information:

  • Speedtest.net website (the original web-based version)
  • Run speedtest-cli using the optional help argument:

How to change your SSH port from the default of 22 on Ubuntu 14.04

A little security through obscurity by changing the SSH (Secure Shell) port on your server from the default of 22.

This page explains how to change the SSH (Secure Shell) port from the default of 22. Using port 22 doesn’t make your system insecure, nor will changing the port from 22 provide any significant variance in security. However, changing the default SSH port will help stop many automated attacks by making it a bit harder to guess which port the secure shell (SSH) is accessible from. In other words, security though obscurity.

1. Connect to your server via SSH

Connect to your server using an SSH client such as PuTTY (for Windows) or OpenSSH for Mac/Linux

2. Edit the /etc/ssh/sshd_config file using root permissions

To edit the file using ‘nano’:

3. Locate the line that looks like one of the following:

4. Edit the line to remove the # and change 22 to the SSH port number you’d like to use.

For example:

Save and exit. If using nano, press Control-X, then Y, then hit Enter.

5. Restart the sshd service on your server

Type the following command:

You should see something like this:

6. Ensure that you’re able to connect using the new port.

Before disconnecting, we recommend verifying that you’re able to connect using the new port. If you can’t, try repeating the above steps with another port or switch back to 22.

Use your your preferred SSH client (see Step #1) or type the following from your existing shell, replacing 59522 with the port number chosen in Step #4:

For more information: