Sunday, April 26, 2026

Installing Python and Creating Virtual Environment for Pip for package installations in Ubuntu

Hi,

In this post we are going to look at how to install Python and PIP and installing packages in virtual environments..

Without wasting any more time let dive into the topic...

Installing Python in Ubuntu
I am here assuming that you do not have prior installation of python...having assumed the case the installation of python is very straight forward.

> sudo apt update
> sudo apt upgrade
> sudo apt install python3
> sudo apt install python3-pip
> sudo apt install python-is-python3

The first two commands update and upgrades the ubuntu operating system, the third installs the python to be precise python3 and the one before last installs the python package manager.

The last command is for the simplication...i.e we do not have to type "python3" at the command line to have the python console rather the command "python" is enough

To confirm the installation use the following commands

> python3 --version
> pip3 --version

After having installed python and its package manager we may need to install certain packages that are required for some specific tasks during programming...

To perform those package installations we have to have virtual environment for python.

To create one follow the steps given below...

> sudo apt install python3-venv
the above command installs the packages required to create a virtual environment

Creating a Virtual Environment 
> python3 -m venv <environment-name>
the above actually creates a virtual environment for the python packages, simply a directory in your preferred location.

 Activating the Virtual Environment 
> source <environment-name>/bin/activate
the above command is to activate the virtual environment, when we install a python package using pip, the package installed is made available only in this virtual environment.

De-Activating the Virtual Environment
> deactivate

Removing the Virtual Environment
> rm -rf <path-to-the-virtual-environment>/<virtual-environment-dir> 


With this we have successfully installted python3...
Have great time reading... thanks.

Sunday, February 1, 2026

Changing the password of the root user of mysql in Ubuntu

Hi all, 
 
In this post we are going to see how to reset the password of root user in mysql

As we all know the root user of mysql is something like the root user of linux with full power to access anything in MySql database server.

Normally during the install, the installation would not ask for password to set for the root user.

This post talks about setting the password in ubuntu for the root user in a precise manner.

This post assumes that you already have a valid MySql Server instance up and running and I am going to use the command line tool i.e the Terminal for connecting to the server and resetting the password.

Let's start it...

Open a terminal and check whether the MySql server is up and running....
> sudo systemctl status mysql
 
If the server is up and running, then you would have response something like given below...


Stop the Server(MySql Server) using the command given below
> sudo systemctl stop mysql
Now we have the server stopped.
 

We have to start the MySql Server differently to have the passord reset for the user root, to do that you must edit mysqld.cnf file located in /etc/mysql/mysql.conf.d folder...

Now open mysqld.cnf file in your favourite editor and try to locate the group [mysqld], you can use the picture below to locate...



At the top of the group or just below the line which contains the content [mysqld]
add the line as said below
skip-grant-tables
Now the configuration file should appear something like the one shown below...




Save the file and exit from the text editor

Now try to start the server using the terminal as given below...
> sudo systemctl start mysql
Check the status of the mysql process
> sudo systemctl status mysql
you should have something like given below...


Connect to mysql server from the command using the command "mysql"
> mysql --user=mysql
Now you should be connected to the server and what you see on the server is the response connected to the server without the password for the user "mysql"


Change the password of the user "root" using the statements given below...

mysql> use mysql;
mysql> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
mysql> flush privileges;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password';

Now stop the server and revert back the changes that we made in mysqld.cnf file and start the server...

Connect to the server now using the password switch..
> mysql --user=root --password
Which would ask you to provide the password, provide the one you updated the user with, now you have successfully changed the password of the user "root"


Hope you enjoyed the post, feel free to post your comments...

Thanks.

Installing Python and Creating Virtual Environment for Pip for package installations in Ubuntu

Hi, In this post we are going to look at how to install Python and PIP and installing packages in virtual environments.. Without wasting...