The entire process of phpMyAdmin installation and configuration, as well as solutions to problems.

by bookmarkscjl on 2008-08-26 11:11:39

Today, while debugging a PHP MySQL database and installing phpMyAdmin as a database management tool on my computer, what should have been a simple task turned out to present several issues:

1. The configuration file now requires a secret passphrase (blowfish_secret).

2. #2003 - Server not responding.

3. Unable to load the mcrypt extension; please check your PHP configuration.

**First Issue: "Unable to load the mcrypt extension; please check your PHP configuration."**

1. MySQL database was not installed correctly, and the related MySQL services in the system were not started.

2. The `libmcrypt.dll` file was missing from the system32 directory (`C:\windows\system32`). The solution is to find `libmcrypt.dll` in the PHP directory, copy it to `C:\windows\system32`, and then restart the web service.

3. In the `php.ini` file located in the PHP directory, the semicolon before `extension=php_mcrypt.dll` was not removed, so the corresponding functionality could not be used. The solution is to open the `php.ini` file, locate `;extension=php_mcrypt.dll`, and change it to `extension=php_mcrypt.dll` by removing the leading semicolon to enable it.

4. The MySQL directory lacked read permissions. Correct directory permissions are as follows:

- Administrator: Full Control

- System: Full Control

- User: Read and Execute

All other user permissions should be deleted (or retained if desired, though this reduces security). After adjusting permissions, restart the MySQL and web services (it's recommended to reboot the server after making these changes).

5. If none of the above methods work, try this: Right-click on "My Computer" > Properties > Advanced > Environment Variables > System Variables > New:

- Name: `phpdir`

- Value: `C:\php` (replace with the actual PHP installation directory)

**Second Issue: "The configuration file now requires a secret passphrase (blowfish_secret)"**

Ensure that the correct settings are applied in the `config.default.php` file:

```php

$cfg['Servers'][$i]['auth_type'] = 'cookie';

```

And also:

```php

$cfg['blowfish_secret'] = 'www.piaoyi.org'; // This value can be anything but must not be left blank.

```

This issue caused me quite a bit of frustration. If you follow the configuration method outlined above, this error should not occur. After spending over two hours modifying the `config.default.php` file, I kept encountering the same error, almost reaching the point of despair.

Then, suddenly, it hit me: Changing the authentication type to `http` or `config` did not affect phpMyAdmin, meaning the configuration mode was not being applied. Could another configuration file be influencing phpMyAdmin?

I quickly checked the root directory of phpMyAdmin and found both a `config.sample.inc.php` and an old `config.inc.php` file from a previous version still present! It turns out this old `config.inc.php` file was causing the issue. After deleting `config.inc.php`, I revisited the debug page, and the error disappeared. Problem solved.

It seems that the priority of the `config.inc.php` file in the phpMyAdmin root directory is higher than that of `/libraries/config.default.php`. The system first loads the configuration file in the root directory, followed by the one in the libraries folder. Phew, what a headache, but finally resolved.

**Third Issue: "#2003 - Server not responding"**

This problem is often due to the MySQL database not starting. It is recommended to directly start MySQL via the Control Panel > Administrative Tools > Services. To check whether MySQL has started, look for the process `mysqld-nt.exe` in Task Manager. If it exists, MySQL has started.

**For Beginners:**

These problems may seem trivial, but for newcomers like myself, encountering them for the first time without clear solutions can feel overwhelming. Searching online might lead to many irrelevant or outdated methods. My advice is to stay calm when facing issues, carefully read the documentation, and refer to others' solutions for inspiration. Practice and experimentation are key—no problem is insurmountable!

**Now, let’s discuss the installation and configuration process of phpMyAdmin:**

Since the latest version of phpMyAdmin has been updated to 2.11.5.1, many configuration methods available online pertain to older versions and no longer suit the new requirements. Below, I will outline the steps for configuring phpMyAdmin 2.11.5.1 for local testing under Windows.

1. **Download the phpMyAdmin package:**

Go to the official website at http://www.phpmyadmin.net, click on the "DOWNLOADS" link, choose the "all-languages.zip" version, download it locally, and extract it. Place the extracted files in the designated virtual root directory under a `phpmyadmin` folder (you can name it whatever you prefer). For example, mine is located at `D:\www\phpmyadmin`.

2. **Find and edit the `/libraries/config.default.php` file** (in older versions, this was `config.inc.php` in the root directory) using a text editor that supports UTF-8 encoding.

3. **Search for `$cfg['PmaAbsoluteUri']`:**

Modify it to the URL where you plan to upload phpMyAdmin.

Example: `$cfg['PmaAbsoluteUri'] = 'http://www.piaoyi.org/phpmyadmin/';`

Since I am testing locally, I changed it to `$cfg['PmaAbsoluteUri'] = 'http://localhost/phpmyadmin/';`

Note: Don’t forget the trailing slash `/` and the `http://`.

4. **Search for `$cfg['Servers'][$i]['host'] = 'localhost';`** (usually default is fine, but exceptions exist).

5. **Search for `$cfg['Servers'][$i]['auth_type'] = 'config';`**

Use `config` for local debugging, and use `cookie` for hosting on a remote server. Since we already added the URL earlier, modify it to `cookie`.

Personally, I recommend setting `auth_type` to `cookie` for both local and remote setups for better security.

Additionally, when setting `auth_type` to `cookie`, another modification is required:

```php

$cfg['blowfish_secret'] = '';

```

Change it to:

```php

$cfg['blowfish_secret'] = 'www.piaoyi.org';

```

Define this string yourself (up to 46 characters). Leaving it blank will result in the second error mentioned earlier: "The configuration file now requires a secret passphrase (blowfish_secret)."

6. **Search for `$cfg['Servers'][$i]['user'] = 'root';`** (username, typically `root` for local use; on remote servers, it's usually your FTP username provided by your hosting provider).

7. **Search for `$cfg['Servers'][$i]['password'] = '123456';`** (change `123456` to the password used to connect to your MySQL database).

8. **Search for `$cfg['DefaultLang'] = 'zh';`** (language selection, `zh` for Simplified Chinese) and `$cfg['DefaultCharset'] = 'gb2312';` (set the default encoding to GB2312).

At this point, the phpMyAdmin configuration is complete. You can now access the convenient graphical management tool at `http://localhost/phpmyadmin/`. Other options in the configuration file not covered here can be ignored or left unmodified. Specific operations within phpMyAdmin are beyond the scope of this article, but its graphical interface is intuitive and easy to understand.