Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lokeshvasnik/0a67b8500e890c8f3e78da3daeb90445 to your computer and use it in GitHub Desktop.
Save lokeshvasnik/0a67b8500e890c8f3e78da3daeb90445 to your computer and use it in GitHub Desktop.
Accessing PHPMyAdmin from Host Machine
Accessing PHPMyAdmin from Host Machine
To access PHPMyAdmin from your host machine, you’ll need to ensure that PHPMyAdmin is
installed on your Ubuntu VM and that remote access is configured correctly. Here’s how you can
do it:
1. Install PHPMyAdmin:
o Run the following command to install PHPMyAdmin:
o sudo apt install phpMyAdmin
Webserver to configure  apache2
Configure database for phpMyAdmin with dbconfig-common  Yes
MySQL application password for phpMyAdmin  bcapasswd2024
2. Configure Apache to Work with PHPMyAdmin:
o Enable the PHPMyAdmin configuration to Apache:
o sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/confavailable/phpmyadmin.conf
o sudo a2enconf phpmyadmin
o sudo systemctl reload apache2
3. Allow Remote Access:
o Edit the Apache configuration file for PHPMyAdmin to allow access from your
host machine’s IP address.
o cd /etc/phpmyadmin
o sudo nano apache.conf
o Add a line Allow from YOUR_HOST_IP under the <Directory
/usr/share/phpmyadmin> directive.
To Save  Crtl + X , Type “Y” and then press “Enter”.
o Restart Apache to apply the changes:
o sudo systemctl restart apache2
4. Configure MySQL User for Remote Access:
o By default, MySQL is configured to listen only on localhost. To allow remote
connections, you need to create a new user or modify an existing user with
remote access privileges.
o Log in to MySQL:
o sudo mysql -u root -p
o Create a new user or grant privileges to an existing user:
SQL
CREATE USER 'phpmyadmin_user'@'%' IDENTIFIED BY 'password';
This command creates a user in MySQL with
username: phpmyadminuser and password: password
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin_user'@'%' WITH GRANT
OPTION;
FLUSH PRIVILEGES;
EXIT;
5. Access PHPMyAdmin:
o Open a web browser on your host machine.
o Navigate to http://YOUR_VM_IP/phpmyadmin.
o Log in with the username and password you set for the MySQL user.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment