In the Linux operating system, MySQL is a popular relational database management system that can be installed and used on different platforms. This article will introduce how to install and configure the MySQL service in the Linux operating system.
1. Install MySQL
sudo service mysql status
If MySQL is not installed in the system, it will prompt that the MySQL service is not running, otherwise the running status of MySQL will be displayed.
sudo apt-get install mysql-server
You can use the following command to install on the CentOS system:
sudo yum install mysql-server
At this point, the system will automatically download and install the MySQL service package.
sudo service mysql status
2. Configure MySQL
mysql -u root -p
After connecting, you need to enter the password of the MySQL root user to enter the MySQL management interface.
a. Enter the following command at the MySQL command line:
CREATE USER 'New user'@'localhost' IDENTIFIED BY 'Password';
Among them, the new user represents the user name you want to create, and the password is the password you set.
b. Authorize the database that new users can access:
GRANT ALL PRIVILEGES ON database name.* TO 'new user'@'localhost';
Among them, database Name the database you want to authorize.
sudo service mysql restart
At this time, the MySQL service has been installed and a new MySQL user has been successfully configured.
3. Using MySQL
In Linux systems, you can use the command line or MySQL GUI tools such as phpMyAdmin to manage MySQL databases.
In the command line, you can use the following command to connect to the MySQL service:
mysql -u username-p
The username is the MySQL user name you created, and then enter the password to enter the MySQL management interface.
If you are not familiar with the command line environment, you can also choose to use the MySQL GUI tool to manage the MySQL database. For example, phpMyAdmin is a popular MySQL management interface. You can use the following command to install phpMyAdmin:
sudo apt-get install phpmyadmin
After the installation is complete, you can enter the phpMyAdmin management interface by entering http://localhost/phpmyadmin in a web browser .
Database management can be easily performed through these tools. Such as creating a new database, creating a new data table, inserting data and other operations.
Summary
Installing and configuring the MySQL service in the Linux operating system is a basic task. In this article, we introduced how to install the MySQL service, perform some basic configurations on it, and finally introduced how to use the command line or the MySQL GUI tool to manage the MySQL database. Through these basic operations, you can easily manage data and improve work efficiency.
The above is the detailed content of How to install Linux mysql service. For more information, please follow other related articles on the PHP Chinese website!