Enabling Remote Access To MySQL
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:
/etc/my.cnf
and comment out or delete this line:
bind-address 127.0.0.1
to
#bind-address 127.0.0.1
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'
where:
- GRANT ALL PRIVILEGES ON – Gives full access to…
- *.* – All tables. May be replaced with database or schema name
- ‘root’ – user to grant permission to. May be replaced with other user names
- ‘%’ – Any host wildcard. Can be replaced with domain or IP address to allow user to connect from
- ‘password’ – The password for the user. May had different passwords for different domain / location of connection e.g localhost can have one password and 192.168.0.1 may have another
Restart MySQL:
sudo /etc/init.d/mysql restart
About Danny
I.T software professional always studying and applying the knowledge gained and one way of doing this is to blog.
Danny also has participates in a part time project called Energy@Home [http://code.google.com/p/energyathome/] for monitoring energy usage on a premise.
Dedicated to I.T since studying pure Information Technology since the age of 16, Danny Tsang working in the field that he has aimed for since leaving school.
View all posts by Danny →
This entry was posted in
Linux,
Networking,
Software and tagged
Linux,
mysql,
privileges,
remote access. Bookmark the
permalink.