What are the steps to install MySQL in Ubuntu?

The steps to install MySQL on Ubuntu are as follows:

  1. To update the apt package manager: First, run the following command to ensure that the apt package manager is up to date:
sudo apt update
  1. Install MySQL Server: Execute the following command to install the MySQL Server:
sudo apt install mysql-server
  1. Start the MySQL service: Once installation is complete, the MySQL service will start automatically. You can use the following command to check the status of the MySQL service:
sudo systemctl status mysql
  1. Secure setting: Execute the following commands to enhance the security of the MySQL server and remove default users and databases.
sudo mysql_secure_installation
  1. To log in to MySQL server, you can use the following command.
sudo mysql -u root -p
  1. To create a new user and database, you can refer to the following command:
CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE new_database;
GRANT ALL PRIVILEGES ON new_database.* TO 'new_user'@'localhost';
FLUSH PRIVILEGES;

In this way, you have successfully installed and configured the MySQL server on Ubuntu.

Leave a Reply 0

Your email address will not be published. Required fields are marked *


广告
Closing in 10 seconds
bannerAds