When it comes to granting someone (e.g to a friend or a site-developer) an access to MySQL databases, security issues and misunderstandings occur. Granting full access to the hosting account in order to modify one database is neither comfortable nor secure.
This article will guide you how to grant a remote access to a single MySQL database that is located on our shared server, without revealing hosting account password.
Since remote access to MySQL databases is disabled on our servers for security reasons, the only solution to connect there is to setup an SSH-tunnel.
In order to grant a remote access to a single MySQL database without sharing cPanel password you will need the following:
1) Dedicated/external/white IP-address. (Please contact your Internet Service Provider in order to check/obtain it)
2) SSH client (It is possible to find download links at this page )
3) Installed and configured properly PHPMyAdmin application on your Hard Drive Disc (see instructions below)
- phpMyAdmin installation and configuration guide:
For Windows users:
Open this page and download the latest WAMP (Windows, Apache, MySQL, PHP) server:
Download the latest release of WampServer.at http://www.wampserver.com/en/download.php
Choose the proper version in order to avoid errors.Once WampServer is downloaded, navigate to the installation folder and start the installation.
It is possible to start WampServer after installation is complete:
These icons show the status of WampServer:
Caution! If this icon turns yellow, then you should check if no other program conflicts with wamp, such applications can be: Xampp, phpEasy, IIS, Skype, Zonealarm, firewall/antivirus, NOD32, Teamweaver and etc.
In order to check that please do the following:
- Select Start button -> click on "Run…" option;
- In the next window type in cmd and press Enter;
- Type “netstat –aon” and press Enter.
- Check what process ID is using 80 port at 0.0.0.0. IP-address.
According to the screenshot, PID (ProcessID) 7932 uses 80th port at the moment.
It is possible to find and disable process with the help of any process exploring tool (e.g. Task Manager or Process Explorer). Skype can be the reason of a failure.
It is possible to use both Skype and Wamp by disabling 80th port usage in Skype (Tools->Options->Advanced->Connection and uncheck the box "Use 80 and 443 as alternatives for incoming connections". Skype should be restarted)
Once that is done, WampServer would be running properly. It is possible to check if your IP is dedicated by accessing your IP-address in browser. In order to check IP-address please visit http://ip.web-hosting.com
If WampServer page is loaded at http:// your.ip / then your IP-address dedicated and it is possible to setup remote access to a single MySQL database.
If “403 Forbidden error” is shown then configuration file at \wamp\alias\ phpmyadmin.conf should be adjusted.
It is possible to open that file with a Notepad. To give access to phpmyadmin from outside, replace “Deny from all” line by “Allow from all”.
Otherwise add “Allow from *ip-address*” line only, where *ip-address* is the ip-address of a person you would like to grant the access to databases.
Once that is done – save changes and click on Wamp icon, select “Stop All Services”
Configure \wamp\apps\phpmyadmin3.4.5\ config.inc.php file now:
Please change some of default settings with the following lines:
$cfg['Servers'][$i]['verbose'] = '127.0.0.1';
$cfg['Servers'][$i]['host'] = '127.0.0.1';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['auth_type'] = 'http';
$cfg['Servers'][$i]['user'] = ‘ ‘
$cfg['Servers'][$i]['password'] = ‘ ‘
Make sure to fill in username and password with proper cPanel account credentials, e.g.
$cfg['Servers'][$i]['user'] = ‘cPanel_account_username‘
$cfg['Servers'][$i]['password'] = ‘cPanel_account_password‘
Create SSH-tunnel in accordance with this tutorial .
Please be advised that SSH-tunnel should be created each time before wamp-server is started.
- Access to phpmyadmin via web-browser.
Click on WampServer icon, select “Start All Services”.
Click on phpMyAdmin link.
phpMyAdmin would connect through ssh-tunnel to MySQL databases on our shared server.
Once someone tries to open “http://your_ip/phpmyadmin/ in browser, authentication request form would appear. Database username and password should be filled there in order to access to the single database. This information can be provided to those people who should have access to the database, but should not have access to the whole cPanel account.
As an example: username “odrpr_1234” is assigned to “odrpr_123” database.
Once proper username and password is filled, remote access to the single MySQL database is provided:
It is highly recommended to follow this step-by-step guide in order to avoid any issues.