LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 04-13-2009, 10:24 AM   #1
another 1
Member
 
Registered: Nov 2008
Posts: 65

Rep: Reputation: 15
how to connect to mysql that uses ssl from PHP


hi. i am trying to connect to mysql using PHP. it worked fine when there was no ssl. but i don't know how to connect to an account that require ssl.
that account set as follow
GRANT SELECT, INSERT ON *.* TO 'khalid'@'192.168.0.2' REQUIRE SSL;
i could connect from the terminal. but i don't know how from the php when the account uses ssl.
 
Old 04-13-2009, 11:18 AM   #2
Robhogg
Member
 
Registered: Sep 2004
Location: Old York, North Yorks.
Distribution: Debian 7 (mainly)
Posts: 653

Rep: Reputation: 97
Are you trying to:
  1. Use PHP to connect to a database running on another machine, from 192.168.0.2; or
  2. Connect to a LAMP server from a client machine with IP address 192.168.0.2, over SSL?
If 1 is the case, mysql_connect can take "client flags" as an optional attribute, one of which is MYSQL_CLIENT_SSL. If 2 is the case, on the other hand, and the PHP scripts are on the same machine as the MySQL server, then the problem is that PHP is connecting from localhost, not from the IP of the client machine, so your GRANT statement would need to allow this. You could enforce the use of SSL by checking the value of $_SERVER['HTTPS'] in the script, and redirect the client if an attempt is made to access the page over plain HTTP.

Last edited by Robhogg; 04-13-2009 at 11:24 AM.
 
Old 04-21-2009, 08:03 AM   #3
another 1
Member
 
Registered: Nov 2008
Posts: 65

Original Poster
Rep: Reputation: 15
thank you very much. i found two ways. either using stunnel and this is the easiest way.
the problem that the PHP and the mysql documentations are horrible.
It seem that you are an expert in the security parts. i am now trying to configure the apache server to block some people and allow other based on their certificates. hope that you are not very busy to answer my questions.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
can't connect php to mysql on RHEL5.0 in phpinfo page --without mysql is there vinayakbane Linux - Newbie 1 02-14-2009 11:47 PM
is there a client install for MySql so PHP can connect to MySQL Server? alar Linux - Software 8 07-03-2007 07:42 PM
Apache + SSL + PHP + Mysql rjbandura Linux - Software 5 07-01-2004 12:31 PM
Apache Jail with SSL, PHP and MySQL dai Linux - Security 3 07-05-2003 06:35 AM
RH9 Apache/SSL/PHP/MySQL RPM vs tar.gz Ani Linux - Newbie 5 04-26-2003 10:43 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 02:27 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration