Posts Under Category: Tutorials

Following command will install MySQL on a CentOS server / VPS.

Login to your server as root via SSH, and run following command.

Step 1:

yum install mysql-server
service mysqld start

Step 2:

Set MySQL server root password.

sudo /usr/bin/mysql_secure_installation

MySQL server will ask MySQL server root password. Since you just installed mysql, there is no MySQL root password. So, just press enter.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

MySQL will prompt you to set a root password. Press Y to set mySQL server root password.

Set root password? [Y/n]

Enter and re-enter root password for MySQL server. Please use a strong password and do not use your server root password.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

Now MySQL will ask a series of questions. Press Y for all.

Remove anonymous users? [Y/n]
Disallow root login remotely? [Y/n]
Remove test database and access to it? [Y/n]
Reload privilege tables now? [Y/n]

At the end MySQL will show success message.

All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Done!!!

Our Recommended VPS Hosting

You should open only limited ports for incoming and outgoing traffic on a server. You can use firewall like CSF firewall to open only trusted ports on a server.

If you want to check all open/listening ports that your server is using, run below command via SSH:

netstat -an

OR

netstat -tulp

OR

netstat -tulpn

The command will print a list of all open ports, protocol using the port, local address and foreign address (IP).

Our Recommended VPS Hosting

For security reason, it is highly recommended that you use SSH key to login to your server via SSH instead of using root password. In this tutorial I will explain how to use SSH key to login to your server via SSH as root user.

Step 1:

Disable SSH Password Authorization Tweak. For security reason, you should disable SSH Password Authorization Tweak from:

WHM Home >> Security Center >> SSH Password Authorization Tweak

disable-password-auth

Step 2:

Now we will generate SSH key on a cPanel server. In WHM, navigate to:

WHM Home >> Security Center >> Manage root’s SSH Keys

And click Generate a New Key.
manage-root-key

Step 3:

Fill the form for the new SSH key and click Generate Key button. Key name can be anything like your server name or your name. Use a strong key password. Please note, you should not use your root password.
manage-root-key

Step 4:

In this step we will authorize the key. Click Manage Authorization for the key that we have generated.
authorize-ssh-key
And Authorize this new key.

Step 5:

In this step we will download the SSH key. Click View/Download Key under Private Keys section.
view-download-ssh-key

Enter the password that you have used in step 3 while generating this key and click convert button.
convert-ssh-key

Step 6:

Copy the key and paste it on a notepad file. Save this text file as ssh.ppk on your computer. Please note, you may use different name for this ssh key file, but you must use .ppk extension.
putty-ppk-ssh-key

Step 7:

So, we have generated and downloaded the SSH key. To use this SSH key with putty, we need to download Pageant.
Download Pageant

Step 8:

After downloading pageant, run it and click Add Key button.
pageant

Browse and select the ssh.ppk file that we have saved in step 6. Pageant will ask for password. Enter the password that you have used in step 3. This will add the key in pageant.
pageant-enter-password

Step 9:

Start putty and try to login to your server as root.
ssh-login

Done!! You will get logged in to your server as root user.

Our Recommended VPS Hosting

For security reason, it is recommended that you change your server default SSH port from 22 to any other port. We have a detailed step by step tutorial for changing SSH port.
How to change SSH port of a Linux server

But if you have forgot your server new SSH port number, or if the new SSH port is blocked at server, here is how you can reset SSH port back to default 22 port on a cPanel server.

Step 1:

Login in WHM of your server using root.

http://serverip:2086

Step 2:

Add following url at the end of your WHM url and run it.

scripts2/doautofixer?autofix=safesshrestart

The final url may be like:

http://serverip:2086/scripts2/doautofixer?autofix=safesshrestart

Your server SSH port is now reset to default 22. If its not working, you may need to restart SSH from

WHM >> Restart Services >> SSH Server

Our Recommended VPS Hosting

In this tutorial, I will explain how to update cPanel License key of a server / vps. cPanel license key can be updated from SSH. You need to update your server license key when you have a new licence key, or you want to upgrade from trail version to paid version.

Login to your server as root and via SSH and run following command

/usr/local/cpanel/cpkeyclt

Done!!

Now try to login in WHM using URL: http://server-ip:2086 OR http://server-ip/whm

Our Recommended VPS Hosting

If you want to see CPU details of your Linux server / VPS, here is how you can check.
Login to your server as root and via SSH, and run following command:

cat /proc/cpuinfo

This will show you your server CPU details like Total processors, CPU model number, speed, cache.

Our Recommended VPS Hosting

Using below commands you can start, stop and restart MySQL from SSH.
Login to your server as root via SSH, and run following commands.

Start MySQL

service mysql start

OR

/etc/init.d/mysql start

Stop MySQL

service mysql stop

OR

/etc/init.d/mysql stop

Restart MySQL

service mysql restart

OR

/etc/init.d/mysql restart

Status of MySQL

If you want to know the status of MySQL on your server, run below command.

service mysql status

read more

Use following command to know the hostname of your server.

hostname

You should run above command in SSH as root user.

Our Recommended VPS Hosting

If you want to check how much disk space your server has, how much disk has been used and how much free disk space is left on your Linux server, here is simple command for that.

Login to your server as root via SSH and run following command.

df -h

This will show size, Used, Available, File system mount points.

If you want to check disk usage summery of any particular directory, say /home use below command:

df -h /home

Our Recommended VPS Hosting

If you want to see the list of users who are logged in server and their IP and what they are doing, here is how you can do.

Login to your server as root and run following command.

w

OR

who

Above command will list all logged in users, their IP, what they are doing.

Our Recommended VPS Hosting