MySQL is one of the most widely used relational database management systems (RDBMS) Known for its reliability, speed, and scalability. MySQL is used for data operations like querying, filtering, sorting, grouping, modifying, and joining the tables present in the database. It is the backbone of many modern applications, powering everything from small websites to large-scale enterprise systems. In this article, we’ll walk explain the process of installing MySQL on Linux, starting from the prerequisites to verifying the installation.
Why Install MySQL on Linux?Before diving into the installation process, it’s important to understand the features that make MySQL a popular choice for database management:
The installation process of MySQL on Linux involves using the terminal and running a series of commands. This articles covers the installation on Ubuntu and other Debian-based distributions, but the steps are similar for other Linux distributions as well.
Step 1: Update Your Package ListBefore installing any software, it’s always a good idea to update your package list to ensure you’re getting the latest version available from the repository.
sudo apt updateStep 2: Install MySQL Server
Now, let’s install the MySQL server using the following command. Open terminal using Ctrl+Alt+T then copy and paste the following command in the terminal to install MySQL in Linux.
sudo apt install mysql-server
Once you run the command, it will prompt you for your password. Enter it and press Enter then Press "y" to continue.
It will take some time to download and install MySQL in Linux.
Step 3: Verify MySQL InstallationTo verify that MySQL is installed correctly or to know the version enter the following commands in your Terminal.
mysql --version
This confirms that MySQL is installed and ready to use.
Securing Your MySQL InstallationBy default, MySQL is installed with some security vulnerabilities, so it's important to secure your installation. MySQL provides a command to set up basic security settings, such as configuring a password for the root user and removing insecure default settings.
Step 4: Run the MySQL Secure Installation ScriptNow we will set the VALIDATE PASSWORD component to improve Security
sudo mysql_secure_installation
Then press "y" to set the password. Next press "0" for the low-level password or choose as you want to set the password.
Create a password. Then Re-enter the password, then to continue press "y".
Now the whole setup is done. Hence, MySQL installaion is successfully done!
This script will guide you through several security settings:
Once the security configuration is complete, test whether MySQL is running properly:
sudo systemctl status mysql
If MySQL is running correctly, you should see output indicating that the service is active and running. If not, you can start the MySQL service using:
sudo systemctl start mysqlGetting Started with MySQL
Once MySQL is installed and secured, let’s log into the MySQL shell to start using it.
Step 6: Log into MySQLTo get started with MySQL, type the following command to go to the root directory.
sudo mysql -u root
You’ll be prompted to enter the root password you set earlier. Once entered correctly, you’ll be logged into the MySQL shell.
Verify MySQL Installation by Creating a DatabaseTo ensure everything is set up properly, let’s create a database and verify that MySQL is working as expected.
Step 7: Create a DatabaseTo create a new database, run the following command within the MySQL shell:
CREATE DATABASE database_name;Step 8: Show Databases
To view the databases on your system, you can use the following command:
SHOW DATABASES;Step 9: Exit MySQL
To exit the MySQL shell, simply type:
EXIT;
Hence, we have successfully created a database using create database command. You are now ready to start using MySQL. MySQL is the best relational database that will keep all your data secure. Many Companies use MySQL because of its solid data security and is supported by multiple applications. So Install MySQL in Linux now and learn SQL in 30 Days - From Basic to Advanced Level!
ConclusionCongratulations! You’ve successfully installed MySQL on your Linux system and verified its functionality by creating a database. MySQL is now ready for you to start managing your data, running SQL queries, and building robust applications. By following this guide, you’ve also learned how to secure your MySQL installation, which is a crucial step for keeping your data safe. With MySQL installed, you’re now ready to dive deeper into SQL, optimize your databases, and build more sophisticated applications.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4