How To Install Mysql In Ubuntu Using Terminal

MySQL is a popular database management system used by many web applications. Installing MySQL on an Ubuntu machine is a straightforward process that can be done using the Terminal.

Here’s a step-by-step guide on how to install MySQL in Ubuntu using Terminal:

Step 1: Update the package list

Open the Terminal by pressing Ctrl+Alt+T from the keyboard. To make sure that the package list is up-to-date, run the following command:

Step 2: Install MySQL server

To install the MySQL server, run the following command:

During the installation, you will be prompted to choose a root password for MySQL. Enter a strong password and confirm it.

Step 3: Secure the MySQL installation

To secure the MySQL installation, run the following command:

This command will set up a root password, remove anonymous users, disable remote root login, and remove test databases.

Step 4: Verify the installation

To verify that the MySQL server is running, use the following command:

If the server is running, you will see a message confirming it.

Conclusion

You have now installed MySQL on your Ubuntu machine using Terminal. MySQL is a powerful tool that can handle complex data management tasks, so take the time to learn how to use it effectively.

All Commands:

Output:

● mysql.service - MySQL Community Server
     Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor pres>
     Active: active (running) since Fri 2021-08-27 16:05:24 UTC; 17min ago
   Main PID: 9519 (mysqld)
     Status: "Server is operational"
      Tasks: 38 (limit: 1164)
     Memory: 331.9M
     CGroup: /system.slice/mysql.service
             └─9519 /usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysq>

Aug 27 16:05:22 ubuntu2004 systemd[1]: Starting MySQL Community Server...
Aug 27 16:05:24 ubuntu2004 systemd[1]: Started MySQL Community Server.