How to Change Mysql Port Number On Linux Mint 20.2

To change Mysql Port number On linux Mint 20.2

Introduction:

MySQL is an open-source relational database management system. Its name is a combination of "My", the name of co-founder Michael Widenius's daughter, and "SQL", the abbreviation for Structured Query Language

Installation Procedure :

Step 1 : To check the Os verson by using the following command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Linuxmint
Description:	Linux Mint 20.2
Release:	20.2
Codename:	uma

Step 2 : Getting into the mysql shell

root@linuxhelp:~# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 3 : Checking the port number by using the following command

mysql> select @@port;
+--------+
| @@port |
+--------+
|   3306 |
+--------+
1 row in set (0.00 sec)

Step 4 : Quit the mysql shell by using the bellow commands

mysql> \q
Bye

Step 5 : Entering into the Configuration directory by using the below command

root@linuxhelp:~# cd /etc/mysql/mysql.conf.d/ 

Step 6 : Listing the files in the following directory

root@linuxhelp:/etc/mysql/mysql.conf.d# ls -la
total 20
drwxr-xr-x 2 root root 4096 Feb 22 03:47 .
drwxr-xr-x 4 root root 4096 Feb 22 01:29 ..
-rw-r--r-- 1 root root  132 Feb 22 00:59 mysql.cnf
-rw-r--r-- 1 root root 2220 Feb 22 03:47 mysqld.cnf
-rw-r--r-- 1 root root 2219 Feb 22 01:29 mysqld.cnf.save

Step 7 : editing the mysqld.cnf Configuraion file

root@linuxhelp:/etc/mysql/mysql.conf.d# nano mysqld.cnf


# The MySQL database server configuration file.
#
# One can use all long options that the program supports.
# Run program with --help to get a list of available options and with
# --print-defaults to see which it would actually understand and use.
#
# For explanations see
# http://dev.mysql.com/doc/mysql/en/server-system-variables.html

# Here is entries for some specific programs
# The following values assume you have at least 32M ram

[mysqld]
#
# * Basic Settings
#
user            = mysql
# pid-file      = /var/run/mysqld/mysqld.pid
# socket        = /var/run/mysqld/mysqld.sock
# port          = 3344
# datadir       = /var/lib/mysql

Step 8 : Restarting the mysql service by using the below command

root@linuxhelp:/etc/mysql/mysql.conf.d# systemctl restart mysql.service

Step 9 : Entering into the mysql shell

root@linuxhelp:/etc/mysql/mysql.conf.d# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 10 : Checking the port number

mysql> select @@port;
+--------+
| @@port |
+--------+
|   3344 |
+--------+
1 row in set (0.00 sec)
mysql> \q
Bye

Step 11 : Editing the Configuration file

root@linuxhelp:/etc/mysql/mysql.conf.d# nano mysqld.cnf

Step 12 : Restarting the mysql service

root@linuxhelp:/etc/mysql/mysql.conf.d# systemctl restart mysql.service
root@linuxhelp:/etc/mysql/mysql.conf.d# mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28-0ubuntu0.20.04.3 (Ubuntu)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Step 13 : Checking the port by using the below commands

mysql> select @@port;
+--------+
| @@port |
+--------+
|   3306 |
+--------+
1 row in set (0.00 sec)

With this the process of changing port number on mysql has come’s to an end..!!

FAQ
Q
What kind of Database is MySQL?
A
Mysql is a relational database system.
Q
What is the current stable version of MySQL?
A
The latest stable version of MySQL is 8.0.28.
Q
How to backup the table in a database?
A
To backup the table in a database use mysqldump -u root -p database_name table_name > filename.sql
Q
Can we customize the data directory path in MySQL?
A
yes, we can change by editing the MySQL configuration file.
Q
Is it possible to reset Root's password in Mysql?
A
yes, it is possible to reset Root's password in Mysql.