473,395 Members | 1,379 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Security and statement advise

Hi All

I have 2 question, the first one I hope I don't start an argurment !

How secure is MySQL? I have been asked by a client to create a windows based
application that will control / transfer / edit over HTTP. The data will be
held on a MySQL server hosted on a standard IPSs server. I have been writing
apps to do this for a while, but this client will be holding data that will
be covered under the data protection act so they want to know how secure the
data will be.

So as a general rule how hard (or hopefully not easy) is MySQL to hack, or
how secure is it when it can be accessed by external apps? Dose it just rely
on the usernames and passwords?

The second question, I want some advise on the best way to run a query.

I have a list of product IDs, and I am trying to work out how many of each
of the products was ordered between 2 dates, I have done the following but
it take way to long to come back with the results as there could be up to
3000 products

SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS productID2ord,
SUM(IF(product = 'productID3', `ord`, 0)) AS productID3ord, (.and so on but
could be up to 3000 products) FROM theTable WHERE (timestamp >= '1234') AND
(timestamp <= '9876') GROUP BY product ORDER BY product

Thanks in advance

Brian


Mar 21 '06 #1
5 1452
Brian wrote:
Hi All

I have 2 question, the first one I hope I don't start an argurment !

How secure is MySQL? I have been asked by a client to create a windows based
application that will control / transfer / edit over HTTP. The data will be
held on a MySQL server hosted on a standard IPSs server. I have been writing
apps to do this for a while, but this client will be holding data that will
be covered under the data protection act so they want to know how secure the
data will be.

Before I would procede with the current path, I would want to search the
web thoroughly to see what others have said. For every method of
protection in most any system are various ways to hack it. For "data
protection act" related data, I would probably want to use a real
database engine.

search the web for MySQL sql injection security


So as a general rule how hard (or hopefully not easy) is MySQL to hack, or
how secure is it when it can be accessed by external apps? Dose it just rely
on the usernames and passwords?
This will all depend upon how well/how much your ISP is willing to lock
the system down to prevent it from being hacked. I would not bet my CC#
on most of them being that secure as they must allow others to use those
servers. You want it secure, have the "customer" host it themselves and
hire the best security people to design and maintain it. Security
cannot be "bolted on", everything from the application to the OS and
database must be designed from the ground up with security as it's core
not an after-thought.


The second question, I want some advise on the best way to run a query.

I have a list of product IDs, and I am trying to work out how many of each
of the products was ordered between 2 dates, I have done the following but
it take way to long to come back with the results as there could be up to
3000 products

SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS productID2ord,
SUM(IF(product = 'productID3', `ord`, 0)) AS productID3ord, (.and so on but
could be up to 3000 products) FROM theTable WHERE (timestamp >= '1234') AND
(timestamp <= '9876') GROUP BY product ORDER BY product

Add a status field to the record. doing what you are doing will result
in 3000+ fields in the result with a bunch of zeros.. Probably not what
you want.

select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,description order by product;

Case and Point (small dataset - no date field but the effects are the
same...

mysql> select d,
-> sum(if(d='prod1',1,0)) as prod1,
-> sum(if(d='prod2',1,0)) as prod2,
-> sum(if(d='prod3',1,0)) as prod3,
-> sum(if(d='prod4',1,0)) as prod4,
-> sum(if(d='prod5',1,0)) as prod5,
-> sum(if(d='prod6',1,0)) as prod6
-> from t group by d;
+-------+-------+-------+-------+-------+-------+-------+
| d | prod1 | prod2 | prod3 | prod4 | prod5 | prod6 |
+-------+-------+-------+-------+-------+-------+-------+
| prod1 | 3 | 0 | 0 | 0 | 0 | 0 |
| prod2 | 0 | 1 | 0 | 0 | 0 | 0 |
| prod3 | 0 | 0 | 2 | 0 | 0 | 0 |
| prod4 | 0 | 0 | 0 | 1 | 0 | 0 |
+-------+-------+-------+-------+-------+-------+-------+
4 rows in set (0.01 sec)

mysql> select d,count(*) from t group by d;
+-------+----------+
| d | count(*) |
+-------+----------+
| prod1 | 3 |
| prod2 | 1 |
| prod3 | 2 |
| prod4 | 1 |
+-------+----------+
4 rows in set (0.01 sec)


Thanks in advance

Brian


Mar 21 '06 #2
"noone" <no***@nowhere.com> wrote in message
news:Wa****************@newssvr11.news.prodigy.com ...
search the web for MySQL sql injection security


Wouldn't any RDBMS be vulnerable to SQL injection if the application is
designed to allow it?
As I understand the idea, SQL injection is a problem in the application, not
the RDBMS.
http://en.wikipedia.org/wiki/SQL_injection

There's a page in the MySQL manual that covers security issues:
http://dev.mysql.com/doc/refman/5.0/en/security.html and its subsections.

I agree that security must include attention to all components of a system.
The security is only as strong as its weakest link. The security plan must
include constant monitoring and logging, too. You can't rely on any
software to be immune to attack forever.

That said, it's a good start to run the RDBMS behind a firewall and disallow
any access to it except directly from the HTTP server hosting the web apps.
If one relies on the security of MySQL to protect the data, it's too late!

And there are books specifically about database security, for example "The
Database Hacker's Handbook: Defending Database Servers" rates 5 stars out of
5 at Amazon.com.
http://www.amazon.com/gp/product/0764578014/
I haven't read it, but it's on my wishlist. :-)

Finally, hacking experts like Kevin Mitnick say that "social hacking" is
harder to prevent than technological hacking. See
http://www.kevinmitnick.com/ and his books like "The Art of Intrusion". One
should not overlook the need to establish policies to define who has access
to the sensitive data within your organization, how they can grant access to
others, and how their access is logged. Training the staff in these
policies is important.

Regards,
Bill K.
Mar 21 '06 #3
"noone" <no***@nowhere.com> wrote in message
news:Wa****************@newssvr11.news.prodigy.com ...
SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0)) AS
product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS
productID2ord, SUM(IF(product = 'productID3', `ord`, 0)) AS
productID3ord, (.and so on but could be up to 3000 products) FROM
theTable WHERE (timestamp >= '1234') AND (timestamp <= '9876') GROUP BY
product ORDER BY product


select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,description order by product;


I assume the OP's queryuses SUM because it's summing values in the `ord`
column. He uses back-ticks instead of single-quotes, therefore ord is a
column. One cannot assume that ord always contains the value 1, so one must
use SUM instead of COUNT. Otherwise I fully agree with you that this should
be done in one column, not 3000 columns! :)

SELECT product, description, SUM(`ord`) AS productOrd
FROM theTable
WHERE `timestamp` BETWEEN '1234' AND '9876'
GROUP BY product, description
ORDER BY product

Regards,
Bill K.
Mar 21 '06 #4
>>> SELECT product, description, SUM(IF(product = 'productID1', `ord`, 0))
AS product1IDord, SUM(IF(product = 'productID2', `ord`, 0)) AS
productID2ord, SUM(IF(product = 'productID3', `ord`, 0)) AS
productID3ord, (.and so on but could be up to 3000 products) FROM
theTable WHERE (timestamp >= '1234') AND (timestamp <= '9876') GROUP BY
product ORDER BY product


select product, description, count(product)
from thetable
where timestamp between [date1] and [date2]
and status='ord'
group by product,description order by product;


I assume the OP's queryuses SUM because it's summing values in the `ord`
column. He uses back-ticks instead of single-quotes, therefore ord is a
column. One cannot assume that ord always contains the value 1, so one
must use SUM instead of COUNT. Otherwise I fully agree with you that this
should be done in one column, not 3000 columns! :)

SELECT product, description, SUM(`ord`) AS productOrd
FROM theTable
WHERE `timestamp` BETWEEN '1234' AND '9876'
GROUP BY product, description
ORDER BY product

Regards,
Bill K.

Hi Guys

Thanks for you replies, sorry for the delay in replying, PC problems and got
sided tracked
by another project

I will try and explain a little better what i and trying to do with this
statement

I need to create a SQL statement that brings back a list and sum of all
products ordered between two dates but only for a given supplier, if non
were ordered then sum = 0
I have a table of PRODUCTS and table of ORDERS

SELECT * FROM products WHERE supplier = X < this gives me a list of all the
products that are supplied by a given supplier

Now I need to say, select and sum the products from a given supplier between
two dates and return a list of the product name and how many ordered, if
none then would be 0

eg

Product | Total
Product1 | 78
Product2 | 90
Product3 | 78
Product4 | 0
Product5 | 67
Product6 | 0
....

I have had a play round, but just can' seem to work out what I should be
doing
Hope this explains it better

Cheers

Brian
Apr 9 '06 #5
Brian wrote:
Now I need to say, select and sum the products from a given supplier between
two dates and return a list of the product name and how many ordered, if
none then would be 0

eg

Product | Total
Product1 | 78
Product2 | 90
Product3 | 78
Product4 | 0
Product5 | 67
Product6 | 0
...


Okay, thanks, that is good new information about your query.
You need to use an OUTER JOIN if you want all products, including those
for which there are no orders.

One of the tricks of outer joins is that if you need to restrict the
rows in the left-hand table (speaking of left outer joins here), you can
put the conditions in the WHERE clause. But if you need to restrict the
rows in the right-hand table, you need to put the conditions in the ON
clause, because if you use the WHERE clause, it'll only match rows where
the right-hand table is not null.

SELECT p.product, SUM(o.`ord`) AS Total
FROM products AS p LEFT OUTER JOIN orders AS o
ON (p.product = o.product
AND o.`timestamp` BETWEEN '1234' AND '9876')
WHERE p.supplier = X
GROUP BY p.product
ORDER BY p.product

Regards,
Bill K.
Apr 9 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jack | last post by:
Hi, I am trying to update database from asp. However, the finalupdate field is not working here. The finalupdate field is a Access Database field of type yes/no. Any help/advise is appreciated....
7
by: Paul T. Rong | last post by:
A card where I wrote my name and WID (work group ID) was stolen (unfortunately together with other things), therotically the one who have my name and WID can create the same mdw file which I use...
3
by: Mike Marriott | last post by:
Hello all, Newbie Here (please go easy, you cant make me fell more stupid than I allready do) I have a small, but complex data base, in Access 2000, that I am creating, I have allready...
0
by: Patrick.O.Ige | last post by:
This what i got from microsoft! GDluck Dear ASP.NET Customer, This alert is to advise you of the availability of a web page that discusses an investigation Microsoft is currently conducting...
4
by: razvan | last post by:
I need advice about adding security to a web service without using WSE, as the clients will run Win98.
19
by: Steve | last post by:
ASP error number 13 - Type mismatch with SELECT...FOR UPDATE statement I got ASP error number 13 when I use the SELECT...FOR UPDATE statement as below. However, if I use SELECT statement without...
1
by: coosa | last post by:
Dear all, I'm designing a system including the database and the security represents the most crucial aspect of the system; hence for the database security i have implemented the following...
2
by: Robert Ellis | last post by:
Hi, I would be grateful for advice on the following. Server 1 (Windows 2003 Server) COMSRV1 VB6 COM ActiveX EXE NETSRV1 .NET (VB2005) .DLL Workstation 1 (Windows XP Professional) APP1...
18
by: Earl Anderson | last post by:
First, I feel somewhat embarrassed and apologetic that this post is lengthy, but in an effort to furnish sufficient information (as opposed to too little information) to you, I wanted to supply all...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.