Home > Database > Mysql Tutorial > Install mysql under linux

Install mysql under linux

WBOY
Release: 2023-05-08 13:27:37
Original
486 people have browsed it

MySQL is a popular open source relational database management system. It is widely used in web applications and other types of software development. In this article, we will cover the steps to install MySQL on a Linux system.

Step 1: Install MySQL

In Linux systems, MySQL can be installed in various ways, including binaries, source code, package managers, etc. In this article, we will introduce the steps to install MySQL using apt package manager in Ubuntu system.

We first need to update the apt package list on the system. Open a terminal and enter the following command:

sudo apt update
Copy after login

Then execute the following command to install MySQL:

sudo apt install mysql-server
Copy after login

During the installation process, you may be asked to set a MySQL root password. Please note that this password will be used to manage the MySQL server and database.

Step 2: Configure MySQL

After installing MySQL, we need to perform some configurations. Most importantly, we need to ensure that MySQL is only listening on localhost to prevent unauthorized remote access.

Open the MySQL configuration file and enter the following command:

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

In the file, find the following line:

bind-address = 127.0.0.1
Copy after login

If you need to allow remote access, then set the parameters of this line Change to the system's public IP address or "0.0.0.0". However, we recommend allowing only local access as remote access may cause network security issues.

Step 3: Start and Stop MySQL

After configuring MySQL, we need to start the MySQL service. Execute the following command to start the service:

sudo systemctl start mysql
Copy after login

If you want to start the MySQL service automatically when the system starts, you can use the following command:

sudo systemctl enable mysql
Copy after login

To stop the MySQL service, execute the following command:

sudo systemctl stop mysql
Copy after login

If you no longer need the MySQL service, uninstall it using the following command:

sudo apt remove mysql-server
Copy after login

It is important to note that this will completely delete the MySQL program and all data and configuration files associated with it.

Conclusion

In this article, we have covered the steps to install MySQL on a Linux system. Installing and configuring MySQL is a relatively simple task, but ensuring network security is important. Before making any changes, make sure you understand the consequences of your changes.

The above is the detailed content of Install mysql under 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