MySQL and Python are famous database and development software respectively. These are normally installed on Linux-based systems. Let’s see how we can get them installed on Ubuntu server environments.
The first thing to do is to find out what is the version of Python installed on the system. We can find this issuing the following command.
Python –v
Where the –v option specifies to show what is the version of Python installed. The following screenshot shows a sample of the output of the above command.
From the above output, we can see that the version of Python installed is version 2.7.
There is another way to see if Python is installed via the following commands.
Python –V
Python3 –V
The later command is used to see the version 3 of Python installed.
If we want to have the latest version of Python installed, then we need to issue the following statement.
sudo apt-get install python3
The above command will download the necessary packages for Python and have it installed.
To install MySQL, the following steps need to be followed.
Step 1 − Issue the apt-get command to ensure all operating system packages are up to date.
sudo apt-get update
Step 2 − Once all the packages have been updated, it is time to get the packages for MySQL.
sudo apt-get install mysql-server
The above command will start the download of all the relevant packages for MySQL.
Once the download completes and the installation starts, the installer will first ask to configure a root password.
Step 3 − Enter the required password and click the OK button. It will also prompt to re-enter the password.
Step 4 − To see the MySQL process running, run the following command.
ps –ef | grep mysql
The following screenshot shows mysqld which is the daemon process for mysql running in the background.
Step 5 − To configure mysql, run the following command.
/usr/bin/mysql_secure_installation
It prompts to enter the root password which was entered during the installation process.
Step 6 − Enter the password and hit Enter.
Now, it prompts on whether we want to change the root password.
Step 7 − Enter ‘N’ for No and proceed.
Again, it prompts on whether we want to remove the Anonymous access.
Step 8 − When connecting from other machines on this database, it is advised to keep the default options as ‘N’ for both anonymous users and disallow root login remotely.
Step 9 − It is advised to provide the option as No for the options of Remove test database as well. We can enter ‘Y’ to reload the privileges table.
Finally, the configuration of MySQL will be complete.