Home  >  Article  >  Database  >  mysql installation path linux

mysql installation path linux

王林
王林Original
2023-05-18 17:29:081745browse

MySQL is a common open source relational database management system developed by Oracle. Installing MySQL on a Linux operating system is usually one of the skills that administrators need to master. In this article, we will discuss how to install MySQL in Linux system and how to find its installation path.

1. Install MySQL

Installing MySQL on a Linux system is generally divided into the following steps:

  1. Download the MySQL installation package
    You can go to https: //dev.mysql.com/downloads/mysql/ To download the MySQL installation package, you need to select a version and the corresponding operating system. Here, we choose the tar installation package of MySQL 5.7 version.
  2. Extract the installation package
    Extract the installation package to the directory where you want to install MySQL. For example, we will install MySQL in the /usr/local/mysql directory. The decompression command is as follows:

tar -xvf mysql-5.7.22.tar

  1. Create MySQL users and groups
    For security reasons, we need to create a dedicated MySQL users and groups, the command is as follows:

groupadd mysql
useradd -r -g mysql -s /bin/false mysql

  1. Install MySQL
    Switch Go to the decompressed mysql directory and execute the installation command:

./configure --prefix=/usr/local/mysql --with-innodb --with-ssl --with-libwrap

make && make install

After the installation is completed, the MySQL server will be placed in the /usr/local/mysql/ directory.

  1. Configure MySQL
    Copy the MySQL configuration file to the /etc directory and modify the permissions:

cp support-files/my-default.cnf /etc /my.cnf
chmod 644 /etc/my.cnf

Next, add the following content to the /etc/my.cnf file to ensure that MySQL can start automatically after restarting:

[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock

  1. Start MySQL
    Use the following command to start the MySQL server:

/usr/local/mysql/bin/mysqld_safe --user=mysql --datadir=/usr/local/mysql/data &

2. Find the MySQL installation path

Once you have successfully installed MySQL, you can find the MySQL installation path in the following ways.

1. Use the whereis command to find

whereis mysql

The installation path of MySQL is usually listed. For example, on my CentOS system, the output is as follows:

mysql: /usr/bin/mysql /usr/lib64/mysql /usr/include/mysql /usr/share/mysql /usr/share/man/man1/mysql.1.gz

Among them, /usr/lib64/mysql is the installation path of MySQL.

  1. Use the which command to find

which mysql

The response is usually a path, for example, on my CentOS system, the output is as follows:

/usr/bin/mysql

The /usr/bin directory here contains the MySQL executable file, and the MySQL database server program (mysqld) is in the /usr/sbin directory.

  1. Find the MySQL configuration file

The MySQL configuration file my.cnf is usually located in the /etc directory. You can view the MySQL installation path by editing the my.cnf file.

Summary

This article introduces how to install MySQL in a Linux system and how to find its installation path. Installing MySQL in a Linux system is a basic task, and understanding the MySQL installation path will also be helpful in improving operation and maintenance. Whether in a development environment or a production environment, you need to master the installation and configuration methods of MySQL.

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