Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2015
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. To expose MySQL to anything other than localhost you will have to have the following line uncommented in /etc/mysql/my.cnf and assigned to your computers IP address and not loopback
  2.  
  3. #Replace xxx with your IP Address
  4. bind-address = xxx.xxx.xxx.xxx
  5. Or add a bind-address = 0.0.0.0 if you don't want to specify the IP
  6.  
  7. Then stop and restart MySQL with the new my.cnf entry. Once running go to the terminal and enter the following command.
  8.  
  9. lsof -i -P | grep :3306
  10. That should come back something like this with your actual IP in the xxx's
  11.  
  12. mysqld 1046 mysql 10u IPv4 5203 0t0 TCP xxx.xxx.xxx.xxx:3306 (LISTEN)
  13. If the above statement returns correctly you will then be able to accept remote users. However for a remote user to connect with the correct priveleges you need to have that user created in both the localhost and '%' as in.
  14.  
  15. CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypass';
  16. CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypass';
  17. Then
  18.  
  19. GRANT ALL ON *.* TO 'myuser'@'localhost';
  20. GRANT ALL ON *.* TO 'myuser'@'%';
  21. If you don't have the same user created as above, when you logon locally you may inherit base localhost privileges and have access issues. If you want to restrict the access myuser has then you would need to read up on the GRANT statement syntax HERE If you get through all this and still have issues post some additional error output and the my.cnf appropriate lines.
  22.  
  23. NOTE: If lsof does not return or is not found you can install it HERE based on your Linux distribution. You do not need lsof to make things work, but it is extremely handy when things are not working as expected.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement