Home  >  Article  >  Database  >  How to set MySQL environment variables in Windows and Linux

How to set MySQL environment variables in Windows and Linux

PHPz
PHPzOriginal
2023-04-19 14:12:061143browse

MySQL is a widely used open source relational database management system. After installing MySQL, for convenience, you can configure it into environment variables so that it can be called directly from the command line. This article will introduce how to set MySQL environment variables in Windows and Linux systems.

1. Set MySQL environment variables in Windows systems

In Windows systems, in order to enable MySQL to be executed in all directories, you need to add the MySQL installation path to the system environment variables. middle. The following are the specific steps:

1. Find the installation path of MySQL, for example: C:\Program Files\MySQL\MySQL Server 8.0\bin.

2. Right-click the "This PC" icon and select "Properties" in the pop-up menu.

3. In the "Properties" dialog box, select "Advanced System Settings" on the left.

4. In the "System Properties" dialog box, select "Environment Variables".

5. In the "System Variables" tab, find the "Path" variable and double-click to edit it.

6. In the "Edit Environment Variables" dialog box, find the "Variable Value" and add the MySQL installation path at the end, separated by a semicolon. For example: C:\Program Files\MySQL\MySQL Server 8.0\bin;.

7. Close all dialog boxes, reopen the command line window, enter "mysql", and press Enter to test whether the MySQL environment variable is set successfully.

2. Set MySQL environment variables in Linux system

In Linux system, you can set MySQL environment variables by modifying the .bashrc file. The following are the specific steps:

1. Find the installation path of MySQL, for example: /usr/local/mysql/bin.

2. Open the .bashrc file, the command is: "vi ~/.bashrc".

3. In the opened file, add the following code and save:

export PATH=$PATH:/usr/local/mysql/bin

4. Reload .bashrc file to make it effective, the command is: "source ~/.bashrc".

5. Enter "mysql" and press Enter to test whether the MySQL environment variable is set successfully.

Summary:

By adding the MySQL installation path to the environment variable, we can directly call MySQL commands in the command line window, making it more convenient and efficient. Whether in Windows or Linux systems, you only need to follow the above introduction to easily set MySQL environment variables.

The above is the detailed content of How to set MySQL environment variables in Windows and 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