In this post, We will figure out how to change the default port that MySQL/MariaDB information base ties in CentOS 7 and Debian-based Linux machine. The default port that MySQL data set worker is running under Linux and Unix is 3306/TCP.
We believe, You have already installed and running Mysql/MariaDB Server on ubuntu 20.04 LTS.If not you can click on given link to install MySQL/MariaDB on ubuntu.
Step 1: Open the Default Config file
The default port that the MySQL data set worker runs under Linux is 3306/TCP. Utilize the orders underneath to change the default MySQL/MariaDB Database port in Linux.
sudo vim /etc/mysql/mariadb.conf.d/50-server.cnf
port = 3306
port = 3307
Here we have change the port number to 3306 to 3307 under the [mysqld].
Step 2: Restart the Mysql/MariaDB Server
To get new changes in MariaDB/Mysql Server, We need to restart the service, Use the given command for the same.
sudo systemctl restart mysql
Step 3: Verify the Port Number
You need to verify the port number by using the netstat, Execute the given command.
netstat -plntu | grep 3307
Step 4: Login with MariaDB/Mysql Shell
We are ready to use the new port number with MariaDB/Mysql by using the given command.
mysql -h localhost -P 3307 -u root -p
We have successfully change the default port number with MariaDB server on Ubuntu 20.04 server.