
{{ $('Map tags to IDs').item.json.title }}
How to Install MySQL on Ubuntu
MySQL is one of the most popular relational database management systems used for building database-driven applications. This tutorial will walk you through the installation of MySQL on an Ubuntu system.
1. Update Package Index
Before starting the installation, it’s a good practice to ensure that your package manager is up-to-date. Run the following command in the terminal:
sudo apt update
2. Installing MySQL Server
To install MySQL, run the following command:
sudo apt install mysql-server
This command installs the MySQL server along with other necessary packages.
3. Securing the MySQL Installation
After the installation is completed, you should run the mysql_secure_installation
script to set root password and secure your installation:
sudo mysql_secure_installation
This script will prompt you to configure several security options, such as:
- Set a root password
- Remove anonymous users
- Disallow root login remotely
- Remove test database
- Reload privilege tables
It’s recommended to answer Y
(yes) to most prompts for better security.
4. Logging into MySQL
You can log into the MySQL shell using the following command:
mysql -u root -p
You will be prompted to enter the root password that you set earlier.
5. Creating a Database
To create a new database, use the following command in the MySQL shell:
CREATE DATABASE mydatabase;
Replace mydatabase
with your desired database name.
6. Granting User Privileges
To create a user and grant privileges on your new database, run the following commands:
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'username'@'localhost';
Replace username
and password
with your desired username and password.
7. Exiting MySQL
To exit the MySQL shell, simply type:
exit
8. Conclusion
By following this tutorial, you have learned how to install and configure MySQL on your Ubuntu system. MySQL is a powerful tool for managing databases and is widely used in various applications. Continue to explore its features and commands to become proficient in database management!