Linux MySQL server installation is a common operation, whether students, researchers, or system administrators need to do this. MySQL is currently the most popular open database management system in the world, with excellent performance in terms of efficiency, reliability and ease of use. This article will introduce you to the detailed steps of Linux MySQL server installation.
1. Installation source settings
1. Enter the following command in the terminal to configure mysql original
sudo wget -c https://repo.mysql.com//mysql-apt-config_0.8.10-1_all.deb sudo dpkg -i mysql-apt-config_0.8.10-1_all.deb
2. Select the MySQL version, operating system and repository according to the prompts.
3. Update source list
sudo apt update
2. Install MySQL
1. Execute the following commands to install the MySQL server and client
sudo apt-get install mysql-server mysql-client
2. Installation During the process, the two packages will be automatically associated, and you will be prompted to set the root user's password.
3. Starting and stopping MySQL
1. Start the MySQL server through the following command
sudo service mysql start
2. Stop the MySQL server
sudo service mysql stop
4. MySQL configuration
1. View the MySQL configuration file
sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
2. Modify the configuration file information as follows
[mysqld] sql_mode = NO_ENGINE_SUBSTITUTION
5. Connection and testing
1. Enter the following The command connects to the MySQL server. After the connection is successful, you will be asked to enter the password
mysql -u root -p
2. Create a database table file
CREATE DATABASE testdb;
3. Create a table persona and add some data
USE testdb; CREATE TABLE persona(id INT NOT NULL PRIMARY KEY, name VARCHAR(10)); INSERT INTO persona(id, name) VALUES(1, 'Tom'); INSERT INTO persona(id, name) VALUES(2, 'Mary');
4. Query the persona table and check whether the data is added successfully
SELECT * FROM persona;
6. Firewall settings
1. Start the MySQL service
sudo ufw allow mysql
2. Check the firewall information
sudo ufw status
Summary:
Linux MySQL server installation is an essential operation. You need to pay attention to a series of steps such as the configuration of the installation source, the startup and shutdown of the MySQL service, the modification of the MySQL configuration, and the establishment of the database. Being familiar with these operations will allow us to use the MySQL database more quickly.
The above is the detailed content of How to install mysql server on linux. For more information, please follow other related articles on the PHP Chinese website!