Steps to Get or Set Up phpMyAdmin Username and Password
Connect to Your EC2 Instance
Connect to your EC2 instance using SSH:
ssh -i /path/to/your-key.pem ubuntu@your-ec2-instance-public-dns
Access the MySQL or MariaDB Database
If you have MySQL or MariaDB installed, log in as the root user (or another administrative user):
sudo mysql -u root -p
If sudo mysql doesn't work, you can try:
mysql -u root -p
Check Existing Users
Once logged in, you can list the existing users:
sql
SELECT User, Host FROM mysql.user;
Create a New User (if needed)
If you need to create a new user for phpMyAdmin:
sql
CREATE USER 'phpmyadmin_user'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin_user'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Update Password for an Existing User
If you need to update the password for an existing user:
sql
ALTER USER 'existing_user'@'localhost' IDENTIFIED BY 'new_password';
FLUSH PRIVILEGES;
Configure phpMyAdmin to Use the Credentials
Ensure that phpMyAdmin is configured to use the correct MySQL credentials. Edit the config.inc.php file:
sudo nano /var/www/html/phpmyadmin/config.inc.php
Add or update the following lines with your username and password:
php
$cfg['Servers'][$i]['auth_type'] = 'cookie';
$cfg['Servers'][$i]['user'] = 'phpmyadmin_user';
$cfg['Servers'][$i]['password'] = 'your_password';
Save and close the file.
Access phpMyAdmin
Open your web browser and navigate to:
http://your-ec2-instance-public-dns/phpmyadmin
Log in with the username and password you set up.
Additional Tips
Security: For security reasons, avoid using the root MySQL user for phpMyAdmin. Create a dedicated user with limited privileges.
User Permissions: Ensure the user has the necessary permissions to access the databases you need.
Secure Connection: Use HTTPS to access phpMyAdmin to secure the transmission of your credentials.