Drongo_III Posted March 20, 2013 Share Posted March 20, 2013 Hi Guys I need to setup a MySQL user account so I can connect (using PHP) both on the server where MySQL resides and remotely from another server (these are load balanced servers). I read a MySQL article here: http://dev.mysql.com/doc/refman/5.1/en/adding-users.html - this seems to suggest in order to do this I would need to setup two user accounts as follows: CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass'; GRANT ALL PRIVILEGES ON MyDB.sometable TO 'monty'@'localhost' CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass'; I am not overly familiar with creating users so apologies for the noob questions about to follow: Is it correct that I need to setup two users with the same username only one as localhost and one with wildcard to be able to use the database locally and remotely ? Rather than use a wildcard would it be more secure to use the remote server's IP - i.e. 'monty'@'SomeIPaddress'? Do I need to grant privileges on the second user - i.e. 'monty'@'%' . Or does this account inherit the same privileges from 'monty'@'localhost'? I would obviously not grant all privileges either but the above is just for simplicity. Is that all I need to do? Thanks Drongo Link to comment https://forums.phpfreaks.com/topic/275943-remote-access-and-setting-up-user/ Share on other sites More sharing options...
fenway Posted March 23, 2013 Share Posted March 23, 2013 1. Well, '%' includes localhost, but typically localhost permissions are less restrictive. 2. Yes, IP would be the best way to go -- usually, web users connect from your web server to your DB server -- and the former almost always has a static/virtual IP (or small range). 3. There is no such inheritance -- one sets of privs for each user/host. More restrictive first, IIRC, in terms of host. Link to comment https://forums.phpfreaks.com/topic/275943-remote-access-and-setting-up-user/#findComment-1420531 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.