Page 1 of 1

PHP to MySQL db connections?

Posted: Mon Mar 17, 2003 7:58 pm
by cleaner
I understand the syntax and parameters of the basic "mysql_connect" command:

$db=mysql_connect("hostname","pw","un");

However, I've read and searched for hours now on mysql security and administration but can't find any specific information on how to connect to a remotely hosted db server using PHP on the web.

1) Do I have to create/grant a specific 'general' user account (un/pw) which can then be used in all my db connection scripts?

2) What is the best security strategy for web-based db connection and transactions?

Thanks in advance :!:

Posted: Tue Mar 18, 2003 2:13 am
by twigletmac
If you want to connect remotely then you need to set up a user on the MySQL database who has the right to connect from your IP address. You then replace 'hostname' in your mysql_connect() function call with the IP of the remote server. You will also (by default) have to have port 3306 open on the remote server so you will need to protect that.

http://www.mysql.com/doc/en/General_security.html
http://www.scibit.com/Help/mascon4linux/faq010.htm

Mac

Posted: Tue Mar 18, 2003 10:40 am
by m3mn0n
Try using phpMyAdmin to do that, they make it very simple.

http://www.phpmyadmin.net/
http://www.mysql.com/doc/en/Privilege_system.html