Home Database phpMyAdmin What should I do if the phpmyadmin directory is not secure?

What should I do if the phpmyadmin directory is not secure?

Jul 21, 2020 am 09:13 AM
phpmyadmin

Solutions to the unsafe phpmyadmin directory: 1. Modify the phpMyAdmin directory name; 2. Add user authentication to the phpMyAdmin directory; 3. Add host-based access control

What should I do if the phpmyadmin directory is not secure?

Solution to the unsafe phpmyadmin directory:

1. Modify the phpMyAdmin directory name:

Do not modify the directory name, it is easy for others to gain insight into the directory name, causing security risks. For example, assuming the domain name of a Linux host is: Client Validation, then without changing the directory name, enter: Client Validation in the address bar and you will enter the phpMyAdmin management program. Therefore, if you rename the phpMyAdmin directory to a directory that is not easy for others to know, such as mynameadmin, then when you manage your own database, you only need to type: Client Validation to manage the database through the browser. (Note: The phpMyAdmin directory name will still be used below. If the directory name has been changed, just rename phpMyAdmin to the new directory name.)

2. Add user authentication to the phpMyAdmin directory:
This is a commonly used method when many websites require user verification. In this way, when the user browses and enters the directory for the first time, a prompt window will appear, prompting the user to enter the user name and password for verification. This is done by using The standard mod_auth module of Apache Server is implemented. The specific operation method is as follows:

1. Edit the Apache Server configuration file with VI and make sure that the following two sentences are not commented in the file. If these two sentences If there is a "#" symbol before the words, remove the "#" symbol.

 DocumentRoot /data/web/apache/public/htdocs
  AccessFileName . htaccess 
  AllOerride All
Copy after login

2. The passwd program creates a user file:

  htpasswd - c /data/web/apache/secrects/.htpasswd 88998
Copy after login

Among them, -c indicates the option to tell htpasswd that you want to generate a new user file. /data/web/apache/secrects/ is the directory where you want to store the .htpasswd file. The file name is .htpasswd, 88998 It is the user name used during verification. After typing the above command, the system prompts you to enter the password. This password is the password needed for verification. The password is encrypted in the .htpasswd file. Now use more to view the /data/web/apache/secrects/.htpasswd file. You can see that there is a line of username and a string of encrypted passwords.

3. Create the .htaccess file:
Use a text editor to create the .htaccess file in the directory phpMyAdmin (if it has been renamed, it will be the new directory name), Add the following statement to the file:

AuthName "用户验证"
  AuthType Basic
  AuthUserFile /data/web/apache/public/htdocs/phpMyAdmin/.htpasswd
require user 88998
Copy after login


After saving the operations, go to the phpMyAdmin directory and a verification window will be prompted. Enter the username and password you just created with the htpasswd command. Enter this directory.

3. Add host-based access control:

After modifying the directory name and adding an access verification mechanism, it should be said that the current phpMyAdmin is very safe. , but since the phpMyAdmin directory is generally only used by database administrators, in order to prevent others from knowing the directory name and verification password, you can also add the following host-based access control. Host-based access is achieved by verifying the user's machine IP, that is, only Only IPs that meet the conditions can query the directory, otherwise access is denied.
Modify.htaccess The file is as follows:

AuthName "用户验证"  
AuthType Basic  
AuthUserFile /data/web/apache/public/htdocs/phpMyAdmin/.htpasswdrequire 
user 88998
order deny,allow  
deny from all  
allow from 202.100.222.80
Copy after login

Three host-based access control instructions are added here. The value of the first order instruction is a list separated by a comma. This The list indicates which command has higher priority. The second command deny defines the hosts that cannot access the directory. The third command allow defines the hosts that can access the directory. In this way, the directory except the IP address 202.100.222.80 Except for the machine that can access this directory, no one else can access it. Readers can use this address as the user database administrator IP.

Summary: By combining the above three points, the security of the phpMyAdmin directory can be well ensured. It will be difficult for non-database administrators to read data through the phpMyAdmin program. What we are talking about here is for the phpMyAdmin directory. If you need to add access restrictions to other directories, you can also follow this method.

Related tutorial recommendations: phpmyadmin

The above is the detailed content of What should I do if the phpmyadmin directory is not secure?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to set primary key in phpmyadmin How to set primary key in phpmyadmin Apr 07, 2024 pm 02:54 PM

The primary key of a table is one or more columns that uniquely identify each record in the table. Here are the steps to set a primary key: Log in to phpMyAdmin. Select database and table. Check the column you want to use as the primary key. Click "Save Changes". Primary keys provide data integrity, lookup speed, and relationship modeling benefits.

Where is the phpmyadmin log? Where is the phpmyadmin log? Apr 07, 2024 pm 12:57 PM

Default location for PHPMyAdmin log files: Linux/Unix/macOS:/var/log/phpmyadminWindows: C:\xampp\phpMyAdmin\logs\ Log file purpose: Troubleshooting Audit Security

How to add foreign keys in phpmyadmin How to add foreign keys in phpmyadmin Apr 07, 2024 pm 02:36 PM

Adding a foreign key in phpMyAdmin can be achieved by following these steps: Select the parent table that contains the foreign key. Edit the parent table structure and add new columns in "Columns". Enable foreign key constraints and select the referencing table and key. Set update/delete operations. save Changes.

Where does the wordpress database exist? Where does the wordpress database exist? Apr 15, 2024 pm 10:39 PM

The WordPress database is housed in a MySQL database that stores all website data and can be accessed through your hosting provider’s dashboard, FTP, or phpMyAdmin. The database name is related to the website URL or username, and access requires the use of database credentials, including name, username, password, and hostname, which are typically stored in the "wp-config.php" file.

What is the password for the phpmyadmin account? What is the password for the phpmyadmin account? Apr 07, 2024 pm 01:09 PM

The default username and password for PHPMyAdmin are root and empty. For security reasons, it is recommended to change the default password. Method to change password: 1. Log in to PHPMyAdmin; 2. Select "privileges"; 3. Enter the new password and save it. When you forget your password, you can reset it by stopping the MySQL service and editing the configuration file: 1. Add the skip-grant-tables line; 2. Log in to the MySQL command line and reset the root password; 3. Refresh the permission table; 4. Delete skip-grant-tables line, restart the MySQL service.

why phpmyadmin access denied why phpmyadmin access denied Apr 07, 2024 pm 01:03 PM

Reasons and solutions for access denied by phpMyAdmin: Authentication failed: Check whether the username and password are correct. Server configuration error: adjust firewall settings and check whether the database port is correct. Permissions issue: Granting users access to the database. Session timeout: Refresh the browser page and reconnect. phpMyAdmin configuration error: Check the configuration file and file permissions to make sure the required Apache modules are enabled. Server issue: Wait for a while and try again or contact your hosting provider.

How to delete data table in phpmyadmin How to delete data table in phpmyadmin Apr 07, 2024 pm 03:00 PM

Steps to delete a data table in phpMyAdmin: Select the database and data table; click the "Action" tab; select the "Delete" option; confirm and perform the deletion operation.

Where is the associated view of phpmyadmin Where is the associated view of phpmyadmin Apr 07, 2024 pm 01:00 PM

Related views can be found in the Views submenu under the Structure tab in phpMyAdmin. To access them, simply select the database, click the "Structure" tab, and then click the "View" submenu.

See all articles