How to install and use MySQL in Ubuntu?
The steps to install MySQL on Ubuntu are as follows:
- Open the terminal and type the following command to update the list of software packages:
sudo apt update
- Install the MySQL server.
sudo apt install mysql-server
- During the installation process, the system will prompt you to set a password for the MySQL root user. Set the password and confirm.
- After installation is complete, you can use the following command to start the MySQL service:
sudo systemctl start mysql
- You can use the following command to check the running status of the MySQL service:
sudo systemctl status mysql
- To automatically start the MySQL service when the system boots up, you can use the following command:
sudo systemctl enable mysql
- Login to the MySQL server using the following command:
mysql -u root -p
- You can log in to the MySQL server by entering the password that has been set.
- Once logged in, you can start using the MySQL database. You can perform operations such as creating databases, creating tables, and inserting data.
- To exit the MySQL server, you can use the following command:
exit;
This way, you can install and use the MySQL database on your Ubuntu system.