
How to Change User Port of MariaDB on Ubuntu 22.04
In our recent post, we checked out the approach for listing users in MariaDB on Ubuntu 22.04. So, today, we will cover the method of changing the user port of MariaDB on Ubuntu.
Changing the user port of MariaDB on Ubuntu typically refers to modifying the port on which the MariaDB server listens for incoming client connections. By default, MariaDB listens on port “3306” for client connections. More specifically, changing the user port involves modifying this default port number to a different value.
How to Change the User Port of MariaDB on Ubuntu 22.04?
Updating or changing the user port of MariaDB on Ubuntu enhances security by making it harder for attackers to target the database. It also helps avoid port conflicts and allows compatibility with specific network configurations or firewall rules. Additionally, changing the user port can help to differentiate between multiple instances of MariaDB on the same server.
In this section, we will specifically demonstrate the method of changing the user port of MariaDB on Ubuntu 22.04.
Step 1: Open Ubuntu Terminal
Hit “CTRL+ALT+T” to open Ubuntu’s terminal:
Step 2: Access MariaDB Shell
Make use of the mentioned command for accessing the MariaDB shell:
sudo mysql -u root -p |
---|
Step 3: Check the Current User Port
Utilize the following command to check the current or default user port:
SHOW GLOBAL VARIABLES LIKE 'port'; |
---|
Here, the current user port of MariaDB is 3306 (default).
Step 4: Exit the MariaDB Shell
For leaving or exiting the MariaDB shell, use the following command:
exit |
---|
Step 5: Open MariaDB Configuration File
Use your preferred text editor for opening the MariaDB configuration file.In our case, we have used nano:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf |
---|
Step 6: Change the User Port
Navigate to the [mysqld] section, and write the line below, if you cannot find it. Otherwise, simply replace the port number:
port=3307 |
---|
Hit “CTRL+O” and “CTRL+X” to save changes and exit the file:
Step 7: Restart MariaDB Service
Changes will take effect once you restart the MariaDB service:
sudo service mysql restart |
---|
How to Verify the Changed User Port of MariaDB?
Execute the following command in the MariaDB shell to verify changes:
SHOW GLOBAL VARIABLES LIKE 'port'; |
---|
As a result, the user port of MariaDB has been changed successfully.
That was all about changing the user port of MariaDB on Ubuntu 22.04.
Conclusion
To change the user port of MariaDB on Ubuntu 22.04, open Ubuntu’s terminal. Then, connect to the MariaDB shell. After that, use the “SHOW GLOBAL VARIABLES LIKE ‘port’;” command to check the current user port and exit the MariaDB shell. Next, utilize the “sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf” command to open the MariaDB configuration file, do the required changes, and restart the MariaDB service to make changes take effect. That’s how you can change the user port of MariaDB on Ubuntu 22.04.