Home >Database >Mysql Tutorial >How to Install MySQL on Ubuntu
MySQL is one of the most popular and widely used relational database management systems in the world. In this article, we will discuss the steps to install MySQL on the Ubuntu operating system.
Before starting the installation process, it is highly recommended to update your system package list. Open a terminal and run the following command:
sudo apt update
Once the package list is updated, you can proceed with installing MySQL server. Use the following command:
sudo apt install mysql-server
During the installation process, you may be asked to confirm the installation. Type Y and press Enter to continue.
After the installation is complete, it is important to secure your MySQL installation. You can do this by running MySQL's built-in security script:
sudo mysql_secure_installation
This script will ask for several options, such as:
We recommend that you choose the option that suits your needs.
After securing the installation, you can check whether the MySQL service is running properly. Use the following command:
sudo systemctl status mysql
If MySQL is running, you will see the status "active (running)".
Now you are ready to access MySQL. Run the following command to enter the MySQL console:
sudo mysql -u root -p
You will be asked to enter the password that you set previously.
After logging into the MySQL console, you can create new databases and users if necessary. Here is an example of how to create a new database and user:
CREATE DATABASE nama_database;
CREATE USER 'nama_pengguna'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON nama_database.* TO 'nama_pengguna'@'localhost';
FLUSH PRIVILEGES;
Once finished, you can exit the MySQL console with the command:
EXIT;
You have now successfully installed MySQL on Ubuntu and secured it. You have also learned how to create new databases and users. With these steps, you are ready to start using MySQL for your projects!
If you have any questions or encounter any problems during the installation process, don't hesitate to ask. Good luck!
The above is the detailed content of How to Install MySQL on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!