db privileges

db privileges

am 06.01.2009 16:41:38 von Patrick Price

------=_Part_167779_8723440.1231256498099
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hey all,

I ran across a problem while trying to run a delete query. The website that
I am working on has multiple users in the db for various logins and I was
inadvertently using a less-privileged account and found I couldn't make
delete queries run successfully. I eventually found out the problem and
changed the db connection but I was wondering if there is a php function
and/or mysql function that can be run from php to find out the privileges
for a particular db connection. Any ideas?

PHP Ver. 5.2.1
MySQL Ver. 5.0.27
on Linux

Thanks

patrick

------=_Part_167779_8723440.1231256498099--

Re: db privileges

am 06.01.2009 17:14:07 von Maximilian Becker

Patrick Price schrieb:
.....

> inadvertently using a less-privileged account and found I couldn't make
> delete queries run successfully. I eventually found out the problem and
> changed the db connection but I was wondering if there is a php function
> and/or mysql function that can be run from php to find out the privileges
> for a particular db connection. Any ideas?
.....

Dear Patrick!

You could query "SHOW GRANTS FOR CURRENT USER".
See: http://dev.mysql.com/doc/refman/5.0/en/show-grants.html

Hope that helps!

Best regards,

Max

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: db privileges

am 06.01.2009 20:08:34 von Frank Flynn

On Jan 6, 2009, at 7:41 AM, php-db-digest-help@lists.php.net wrote:

>
> I was wondering if there is a php function
> and/or mysql function that can be run from php to find out the
> privileges
> for a particular db connection. Any ideas?

Just to get you started try:

select * from mysql.user where concat(user, '@', host) like
(select CURRENT_USER())\G

That worked for me, I'm sure you can go join to INFORMATION_SCHEMA and
do more exotic (more precise) things too.

Good Luck,
Frank

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: db privileges

am 07.01.2009 01:35:24 von Patrick Price

------=_Part_173023_29666214.1231288524983
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hey Frank,

I wasn't able to run the query:
select * from mysql.user where concat(user, '@', host) like (select
CURRENT_USER())

because I didn't have privileges to view the table, but I was able to root
around the INFORMATION_SCHEMA table and find what I needed.

thanks!

patrick

On Tue, Jan 6, 2009 at 2:08 PM, Frank Flynn wrote:

>
> On Jan 6, 2009, at 7:41 AM, php-db-digest-help@lists.php.net wrote:
>
>
>> I was wondering if there is a php function
>> and/or mysql function that can be run from php to find out the privileges
>> for a particular db connection. Any ideas?
>>
>
> Just to get you started try:
>
> select * from mysql.user where concat(user, '@', host) like (select
> CURRENT_USER())\G
>
> That worked for me, I'm sure you can go join to INFORMATION_SCHEMA and do
> more exotic (more precise) things too.
>
> Good Luck,
> Frank
>

------=_Part_173023_29666214.1231288524983--