Below is an example config.inc.php
configuration file for phpMyAdmin to connect to a MySQL server. This example assumes a basic setup where phpMyAdmin is running on the same server as the MySQL server. Adjust the settings according to your server environment and security requirements.
Below is an example config.inc.php
configuration file for phpMyAdmin to connect to a MySQL server. This example assumes a basic setup where phpMyAdmin is running on the same server as the MySQL server. Adjust the settings according to your server environment and security requirements
- Copy the Sample Configuration File:
- If there’s a
config.sample.inc.php
file in the phpMyAdmin directory, you can copy it to create your configuration file. Run the following command in the phpMyAdmin directory:cp config.sample.inc.php config.inc.php
- If there’s a
- Edit the Configuration File:
- Open the
config.inc.php
file in a text editor. Add or modify the following configuration settings to connect phpMyAdmin to your MySQL server:$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL server host
$cfg['Servers'][$i]['port'] = '3306'; // MySQL server port
$cfg['Servers'][$i]['user'] = 'root'; // MySQL server username
$cfg['Servers'][$i]['password'] = 'your_password'; // MySQL server password
$cfg['Servers'][$i]['auth_type'] = 'cookie'; // Authentication type (cookie or config)
// You can add more servers if needed
// $cfg['Servers'][$i]['host'] = 'other_server';
// $cfg['Servers'][$i]['port'] = '3306';
// $cfg['Servers'][$i]['user'] = 'other_user';
// $cfg['Servers'][$i]['password'] = 'other_password';
// $cfg['Servers'][$i]['auth_type'] = 'cookie';
// Optional: Set a blowfish secret for enhanced security
$cfg['blowfish_secret'] = 'your_blowfish_secret';
// Optional: Set a passphrase for cookie authentication
$cfg[‘Servers’][$i][‘AllowNoPassword’] = false;// Optional: Enable SSL for secure connections
//$cfg['Servers'][$i]['ssl'] = true;
//$cfg['Servers'][$i]['ssl_key'] = 'path/to/ssl-key.pem';
//$cfg['Servers'][$i]['ssl_cert'] = 'path/to/ssl-cert.pem';
//$cfg['Servers'][$i]['ssl_ca'] = 'path/to/ca-cert.pem';
// ...
- Replace
'your_password'
with the actual password for your MySQL server. You can also set additional configuration options based on your needs.
- Open the
- Save the Configuration File:
- Save the changes to the
config.inc.php
file.
- Save the changes to the
- Secure phpMyAdmin:
- Consider restricting access to phpMyAdmin, either through web server configuration (e.g., Apache or Nginx) or by using IP whitelisting. It’s essential to take steps to secure phpMyAdmin to prevent unauthorized access.
- Blowfish Secret:
- The
blowfish_secret
is used for cookie encryption. Generate a random string and set it as the blowfish secret for enhanced security.
- The
- SSL Configuration (Optional):
- If your MySQL server uses SSL, you can configure phpMyAdmin to connect securely. Uncomment the SSL-related lines and provide the paths to your SSL key, certificate, and CA certificate.
After making these changes, you should be able to access phpMyAdmin using a web browser and manage your MySQL server. Always follow security best practices, and regularly update both phpMyAdmin and MySQL for the latest security patches.