How to Install MySQL/MariaDB on Ubuntu
Introduction
MySQL and MariaDB are popular open-source database servers used in many web applications. This guide shows you how to install and secure MySQL or MariaDB on Ubuntu.
Step-by-step Guide
- Update your package list
- sudo apt update
- Install MySQL Server
- sudo apt install mysql-servern
- Or, to install MariaDB instead:
- sudo apt install mariadb-server
- sudo apt install mysql-servern
- Start and enable the database service
- For MySQL:n
- sudo systemctl start mysql
- sudo systemctl enable mysql
- For MariaDB:n
- sudo systemctl start mariadb
- sudo systemctl enable mariadb
- For MySQL:n
- Run the security script
- sudo mysql_secure_installationn
- Follow the prompts to set a root password, remove test databases, and secure your installation.
- sudo mysql_secure_installationn
- Log in to the database server
- sudo mysql -u root -pn
- Enter your root password when prompted.
- sudo mysql -u root -pn
- (Optional) Create a new database and user
- CREATE DATABASE mydatabase;
- CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
- GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';
- FLUSH PRIVILEGES;
- EXIT;
Recommendations
- Always set a strong root password.
- Regularly back up your databases.
- Keep your MySQL/MariaDB server updated for security.
Call To Action
eed a reliable VPS for your databases? Check out our hosting plans! https://xernode.com/#pricing