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:
tar -xvf mysql-5.7.22.tar
groupadd mysql
useradd -r -g mysql -s /bin/false mysql
./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.
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
/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.
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.
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!