How to Install MySQL on Ubuntu?
Last Updated :
26 Jun, 2024
Setting up MySQL on Ubuntu is crucial for managing databases efficiently in your development environment. This guide provides a step-by-step walkthrough to help you install MySQL on Ubuntu, ensuring you're ready to store and retrieve data seamlessly.
Ubuntu MySQL installation
Downloading MySQL in Ubuntu involves several steps, by following these steps with proper caution we can easily Get Ubuntu MySQL installed, the steps are as follows:
Step 1: Update the Package Repository
This is the first step. In this step we update the Package Repository because in Ubuntu we have to perform this step manually so that the Latest Repositories are loaded for installation and updation, to do this we will open the terminal and write the following command:
sudo apt update
This will give us the following output:
sudo apt update.Step 2: Install MySQL Package
Now we will have to perform the important step, in this step, we write the following Linux Command that will download and Install the MySQL Package into our system:
sudo apt install mysql-server
This will give us the following output:
sudo apt install MySQL-server.After the above command runs successfully, you can run the below command to check if the MySQL is installed or not:
mysqld –version
This will give us the following output:
mysqld –version.Step 3: Secure the MySQL on Ubuntu
Now once we have verified whether we have Installed MySQL or not, we will need to secure MySQL, we will have first to run the following Ubuntu Command:
sudo mysql_secure_installation
This will give us the following output:
sudo mysql_secure_installation.Step 4: Secure the MySQL - Password Validation
After running the above command, you will see an interface similar to below, when this appears type "Y" to proceed.
Now the user can choose the security level (0 = lowest, 1 = medium, 2 = strong).
Note: After this, if you have already set password for root user, it will ask for that password (like in my case) otherwise it will ask you to create new password for root user.
Step 5: Secure the MySQL - Removal of Anonymous Users
After this it will ask you whether you want to remove the anonymous users or not, if you don't know what this does, it will simply clear any anonymous users to improve security, so again type "Y".
This will give us the following output:
Removal of Anonymous Users.Step 6: Secure the MySQL - Disable the Root Login Remotely
Now for enhancing the security of the MySQL further, we will have to disable the root login remotely option, for this simply type "Y" when it prompts you to disable the login remotely feature.
Step 7: Secure the MySQL - Removal of Test Database
In this step, you can either type "Y" or "N" depending on whether you want to delete or remove the test Database, if you do not need any test database then type "Y":
This will give us the following output:
Removal of Test Database.Step 8: Checking if MySQL Service is Running or Not
Now once all of the above security steps are completed, we will need to check whether the MySQL service is running or not, we can run the following command:
sudo systemctl status mysql
This will give the following output:
sudo systemctl status mysql.Step 9: Login Into the MySQL Server
After checking whether the MySQL server is running or not, we can log in to MySQL whenever we want by running the following command:
sudo mysql -u root
This will give us the following output once we have logged in:
sudo mysql -u root.Conclusion
By following this comprehensive guide to install MySQL on Ubuntu, you've established a robust database management system. Whether for web applications or data-driven projects, MySQL on Ubuntu empowers you with scalable and reliable database solutions.
Also Read
Similar Reads
How to install make on Ubuntu
The "make" program in Linux is used to compile and manage a set of source code applications and files. It allows developers to install and gather a range of apps via the terminal. It also controls and cuts down on the amount of time necessary for compilation. The basic objective of the make command
3 min read
How to Install MySQL WorkBench on Ubuntu?
MySQL Workbench is a powerful and widely-used graphical user interface (GUI) tool developed by Oracle Corporation for managing MySQL databases. It provides a comprehensive set of tools for database administrators, architects, and developers to design, develop, and manage MySQL databases visually. My
3 min read
How to Install Python-PyGreSQL on Ubuntu?
Python-PyGreSQL is a python module that interfaces to the popular PostgreSQL database. Python-PyGreSQL implants the PostgreSQL database query library to permit simple use of the powerful PostgreSQL features from Python script. In this, article, we will look into the steps of installing the Python-Py
2 min read
How to Install PHP on Ubuntu?
If you're working with web development on Linux, knowing how to install PHP on Ubuntu is essential. PHP is a popular server-side scripting language used to build dynamic websites, and setting it up on your Ubuntu system is simple. In this guide, we'll walk you through the steps to PHP installation o
5 min read
How to Install MySQL on Windows?
Installing MySQL on your Windows PC is a straightforward process, but it requires ensuring that your system meets specific hardware and software prerequisites. In this article, We will learn about How to Install MySQL on Windows by understanding each step in detail. What is MySQL?MySQL is an open-so
4 min read
How to install SQLite 3 in Ubuntu
SQLite is a C language package that includes a free and lightweight Relational Database Management System (RDMS). A "client-server" database engine is another name for it. Almost all programming languages have SQLite support built-in, and it may be integrated using the ".sqlite3/.sqlite/.DB" extensi
3 min read
How to Install MySQL on Linux?
MySQL is an open-source relational database management system that is based on SQL queries. Here, "My" represents the name of the co-founder Michael Widenius's daughter and "SQL" represents the Structured Query Language. MySQL is used for data operations like querying, filtering, sorting, grouping,
3 min read
How to Install MySQL on macOS?
MySQL is an open-source relational database managing system. It is used for implementing databases. For any website or any other application, a database is required to store data of websites and applications. Using MySQL server of data can be created. The database created by MySQL is well-organized
5 min read
How to Install MySQL on Fedora?
MySQL is one of the oldest and most reliable open-source (Available to all) Relational Database Management Systems. Trusted by Millions of users. SQL is used to communicate with Oracle, SQL-Server & MySQL. In MySQL, all data are arranged in the form of a table. MySQL is one of the best RDBMS bei
4 min read
Installing MySQL on Ubuntu 20.04
MySQL is a database systeÂm used to store and manage information. It is freÂe for anyone to use and can be easily installed on Ubuntu 20.04, which is a popular operating systeÂm for computers. Installing MySQL on Ubuntu 20.04 is a straightforward process that allows you to set up a powerful relatio
6 min read