Home > Database > Mysql Tutorial > body text

How to install mysql server on linux

PHPz
Release: 2023-04-17 17:14:43
Original
1378 people have browsed it

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
Copy after login

2. Select the MySQL version, operating system and repository according to the prompts.

3. Update source list

sudo apt update
Copy after login

2. Install MySQL

1. Execute the following commands to install the MySQL server and client

sudo apt-get install mysql-server mysql-client
Copy after login

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
Copy after login

2. Stop the MySQL server

sudo service mysql stop
Copy after login

4. MySQL configuration

1. View the MySQL configuration file

sudo vi /etc/mysql/mysql.conf.d/mysqld.cnf
Copy after login

2. Modify the configuration file information as follows

[mysqld]
sql_mode = NO_ENGINE_SUBSTITUTION
Copy after login

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
Copy after login

2. Create a database table file

CREATE DATABASE testdb;
Copy after login

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');
Copy after login

4. Query the persona table and check whether the data is added successfully

SELECT * FROM persona;
Copy after login

6. Firewall settings

1. Start the MySQL service

sudo ufw allow mysql
Copy after login

2. Check the firewall information

sudo ufw status
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template