I recently set up a virtual machine with Linux running on it to test stuff out. I ran into the issue which I have solved many times when I had installed my server at home which has a LAMP set up. By default MySQL restricts access to the database to only root (because this is the only account that have been created) and on the local machine access only.
First edit the MySQL configuration file. On Fedora this is located at:
and comment out or delete this line:
Save the file and edit the permissions in mysql
mysql -u root -p
A password prompt for root should appear. Once logged into MySQL execute this command:
GRANT ALL PRIVILEGES ON *.* TO ''@'%' IDENTIFIED BY 'password'
sudo /etc/init.d/mysql restart