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
Non-linear Components
In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Class Diagram | Unified Modeling Language (UML)
A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Spring Boot Tutorial
Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Backpropagation in Neural Network
Backpropagation is also known as "Backward Propagation of Errors" and it is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network. In this article we will explore what
10 min read
Polymorphism in Java
Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
AVL Tree Data Structure
An AVL tree defined as a self-balancing Binary Search Tree (BST) where the difference between heights of left and right subtrees for any node cannot be more than one. The absolute difference between the heights of the left subtree and the right subtree for any node is known as the balance factor of
4 min read
What is Vacuum Circuit Breaker?
A vacuum circuit breaker is a type of breaker that utilizes a vacuum as the medium to extinguish electrical arcs. Within this circuit breaker, there is a vacuum interrupter that houses the stationary and mobile contacts in a permanently sealed enclosure. When the contacts are separated in a high vac
13 min read
3-Phase Inverter
An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
What is a Neural Network?
Neural networks are machine learning models that mimic the complex functions of the human brain. These models consist of interconnected nodes or neurons that process data, learn patterns, and enable tasks such as pattern recognition and decision-making.In this article, we will explore the fundamenta
14 min read
Use Case Diagram - Unified Modeling Language (UML)
A Use Case Diagram in Unified Modeling Language (UML) is a visual representation that illustrates the interactions between users (actors) and a system. It captures the functional requirements of a system, showing how different users engage with various use cases, or specific functionalities, within
9 min read