Home  >  Article  >  Database  >  mysql installation directory linux

mysql installation directory linux

WBOY
WBOYOriginal
2023-05-18 22:29:39563browse

In Linux systems, MySQL database is one of the most commonly used relational databases. MySQL provides an open source relational database management system (RDBMS). In this article, we will explore the steps on how to install MySQL on Linux.

Installation steps

First of all, you need to install MySQL, and you need to download the corresponding installation package from the official website. Please select the corresponding installation package according to your Linux distribution. Below we take CentOS as an example to demonstrate the installation process of MySQL.

Step 1: Update System Packages

Before installing any new packages, existing packages should be updated on the system. On CentOS systems, you can use the following command to update the package:

sudo yum update -y

Step 2: Add the MySQL installation source

Next, you need to add the MySQL installation source. Of course, you can also download the latest RPM package from the MySQL official website, but using the official MySQL source can easily manage the update and installation of MySQL packages.

MySQL package repository can be added using the following command:

sudo wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

Next, run the following command to install the repository:

sudo rpm -ivh mysql57-community-release-el7-11.noarch.rpm

Step 3: Install MySQL

Now, you can use the following command to install the MySQL server:

sudo yum install mysql-server -y

With the above command, the system will automatically install MySQL and all related files.

Step 4: Start MySQL

Once MySQL is fully installed, you can use the following command to start the MySQL server:

sudo systemctl start mysqld

You can use the following command to check the status of the MySQL server:

sudo systemctl status mysqld

The above command displays the output of the MySQL system status. This is a good way to confirm that MySQL is running.

Step 5: Set up MySQL to start automatically

If you plan to use MySQL as a database server for long periods of time, you may want to configure your system to start MySQL at startup. You can configure auto-start for MySQL using the following command:

sudo systemctl enable mysqld

Step 6: MySQL Security Settings

Once MySQL is installed and started on Linux, it must be security set up by following the steps below.

sudo mysql_secure_installation

The command line prompts you for your root password to continue. After entering it, it will ask you to configure the MySQL password security level. It will prompt you to delete anonymous users and disable remote login for the root user to ensure security.

Step 7: Find the MySQL installation directory

Next, we need to find the MySQL installation directory. This depends on your Linux operating system and version. On CentOS, the MySQL installation directory is usually located at "/usr/bin/mysql".

To find the installation directory of MySQL, use the following command:

which mysql

This will display the installation path of MySQL.

/usr/bin/mysql

As you can see, the installation directory of MySQL on CentOS is located in "/usr/bin/mysql".

Conclusion

On a Linux system, installing MySQL is a simple process. By following the steps listed above, you can install and configure MySQL server on Linux. To ensure security, you should also follow the recommendations for MySQL security settings.

The above is the detailed content of mysql installation directory linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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
Previous article:mysql deduplicationNext article:mysql deduplication