How to Install MySQL Database Server on Linux241


MySQL is a popular open-source relational database management system (RDBMS) that is widely used for storing and managing data. It is known for its high performance, reliability, and scalability. In this tutorial, we will guide you through the step-by-step process of installing MySQL database server on Linux.

Prerequisites

Before proceeding with the installation, ensure that you have the following prerequisites:
A Linux server with a supported operating system (e.g., Ubuntu, CentOS, Red Hat Enterprise Linux).
Root access or sudo privileges.
Internet connection.

Step 1: Add MySQL Repository

Begin by adding the MySQL repository to your system's software sources. This will allow you to install MySQL packages directly from the official repositories.For Ubuntu/Debian:
```
sudo add-apt-repository 'deb /apt/ubuntu $UBUNTU_CODENAME mysql-5.7'
```
For CentOS/Red Hat Enterprise Linux:
```
sudo rpm -Uvh /
```

Step 2: Update System Packages

Once the repository has been added, update your system's package manager to recognize the new repository.For Ubuntu/Debian:
```
sudo apt update
```
For CentOS/Red Hat Enterprise Linux:
```
sudo yum update
```

Step 3: Install MySQL Server

Now, you can proceed with installing the MySQL server package.For Ubuntu/Debian:
```
sudo apt install mysql-server
```
For CentOS/Red Hat Enterprise Linux:
```
sudo yum install mysql-server
```

Step 4: Start MySQL Server

After the installation is complete, start the MySQL server.For Ubuntu/Debian:
```
sudo systemctl start mysql
```
For CentOS/Red Hat Enterprise Linux:
```
sudo systemctl start mysqld
```

Step 5: Secure MySQL Installation

It is crucial to secure your MySQL installation to prevent unauthorized access and data breaches. Run the following command to execute the MySQL security script:```
sudo mysql_secure_installation
```

Follow the on-screen prompts to set a root password, remove anonymous users, disable remote root login, and drop the test database.

Step 6: Verify MySQL Installation

To verify that MySQL is installed and running correctly, connect to the MySQL server and check its version.```
mysql -u root -p
mysql> SELECT version();
mysql> quit
```

Step 7: Create a Database (Optional)

If you want to create a new database, you can do so using the following command:```
mysql -u root -p
mysql> CREATE DATABASE database_name;
mysql> quit
```

Conclusion

Congratulations! You have now successfully installed and secured MySQL database server on your Linux system. You can now start using MySQL to store, manage, and query your data. Remember to регулярно backup your database regularly and keep your MySQL software up to date to ensure the integrity and security of your data.

2024-11-26


Previous:Cloud Computing vs. Distributed Systems

Next:Multithreaded Programming in C: A Comprehensive Guide