How to use MySQL after installing it on Linux?
To install and use MySQL on Linux, you can follow these steps:
- To check if MySQL is already installed in the system, use the following command in the terminal.
mysql --version
If not already installed, you may proceed to the next step.
- Install MySQL: You can use the system’s package manager to install MySQL. For example, in Ubuntu, you can use the following command to install it:
sudo apt-get update
sudo apt-get install mysql-server
During the installation process, the system will prompt you to set a password for the root user.
- Start MySQL service: After installation is complete, the MySQL service will automatically start. You can use the following command to check the status of the MySQL service:
sudo service mysql status
If the service is not started, you can manually start it using the following command:
sudo service mysql start
- Connect to the MySQL server: You can use the following command to connect to the MySQL server:
mysql -u root -p
Then enter the root user password that was previously set.
- To create a database in MySQL, you can use the following command:
CREATE DATABASE database_name;
Replace “database_name” with the name of the database you want to create.
- To use the database: you can use the following command to select the database you want to use:
USE database_name;
Replace “database_name” with the name of the database you want to use.
- Execute SQL command: You can use the following command to execute SQL command:
SQL_COMMAND;
Replace “SQL_COMMAND” with the SQL command you want to execute.
This way, you can install MySQL on Linux and start using it.