Table of Contents
What you will read?
MySQL is one of the most popular open-source relational database management systems used for web applications, software, and data-driven projects.
Step 1: Update Your System
Before installing any new software, it’s a good idea to update your package list and upgrade existing packages. Run the following command in your terminal:
sudo apt update && sudo apt upgrade -y
Step 2: Install MySQL Server
To install MySQL, use the command below:
sudo apt install mysql-server -y
This will install the latest stable version of MySQL available in Ubuntu’s repositories.
Step 3: Enable and Start MySQL Service
Once installation is complete, start and enable MySQL to ensure it runs automatically at boot:
sudo systemctl enable mysql
sudo systemctl start mysql
You can verify the service status with:
sudo systemctl status mysql
Step 4: Secure Your MySQL Installation
MySQL provides a built-in script to improve security by setting a root password, removing anonymous users, and disabling remote root access. Run:
sudo mysql_secure_installation
Follow the prompts and choose options that best suit your setup (usually pressing Y for all).
Step 5: Access MySQL
To access the MySQL shell as the root user, run:
sudo mysql
If you’ve set a password for root authentication, use:
mysql -u root -p
You can now create databases, manage users, and perform administrative tasks.
Step 6: (Optional) Allow Remote Connections
If you need to access MySQL remotely, edit the configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Find the line:
bind-address = 127.0.0.1
and change it to:
bind-address = 0.0.0.0
Then restart MySQL:
sudo systemctl restart mysql
You have successfully installed and configured MySQL on Ubuntu 25.10. This setup is now ready for use with your web applications or development projects.For more detailed Linux and database setup guides, check out our latest articles on DropVPS — where we regularly share practical tutorials and server management tips.
