If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > how to enable/disable a user account in MYSQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-12-06, 05:10
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
how to enable/disable a user account in MYSQL

hi


i have a requirement that i have to enable/disable a user account in MYSQL progrmatically.do we have any command for this ???

thanks in advance
Ramana
Reply With Quote
  #2 (permalink)  
Old 07-14-06, 04:49
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
I doubt if this is possible directly, but you can use GRANT to set permissions to which tables the user has access to, limiting resources or changing the password.
__________________
MySQL 5.1
Reply With Quote
  #3 (permalink)  
Old 07-14-06, 05:07
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
regarding enabling/disabling a user in MY SQL

hi anjanesh

first of all thanks a lot for replying my thread.


as you said i tried ..but efforts went in vain

this is how i tried:

GRANT ALL ON *.* TO david;//assumeing user is "david"

REVOKE ALL PRIVILEGES ON *.* FROM david;

after giveing the above REVOKE COMMAND .when i tries to login with
mysql -u david -ppassword

it is allowing me to login.since REVOKE is applied on david user he should not allow david to login.

please help me in this regard...if you find any command pls send me


thanks in advance
Ramana
Reply With Quote
  #4 (permalink)  
Old 07-14-06, 05:14
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Do FLUSH PRIVILEGES; after every GRANT or REVOKE.
__________________
MySQL 5.1
Reply With Quote
  #5 (permalink)  
Old 07-14-06, 05:22
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
reg enable/disable issue

hi anjanesh

i tried with FLUSH PRIVILEGES also
but no luck..

if you find any other solution pls let me know

thanks in advance
Ramana
Reply With Quote
  #6 (permalink)  
Old 07-14-06, 05:26
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Actually, the full username path should be 'username'@'hostname'

If the hostname of david is localhost then try
Code:
REVOKE ALL PRIVILEGES ON *.* FROM 'david'@'localhost';
__________________
MySQL 5.1
Reply With Quote
  #7 (permalink)  
Old 07-14-06, 05:33
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
hi

i tried with what ever the command u sent just now


i tried with this command::::REVOKE ALL PRIVILEGES ON *.* FROM 'david'@'localhost';

this is the error i am getting...

mysql> REVOKE ALL PRIVILEGES ON *.* FROM 'david'@'localhost';
ERROR 1141 (42000): There is no such grant defined for user 'david' on host 'localhost'

thanks
Ramana
Reply With Quote
  #8 (permalink)  
Old 07-14-06, 05:37
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Ok. Lets see the data directly from the mysql table.
Login as root
Code:
USE mysql;
SELECT `Host`, `User`, `Password` FROM `user`;
What do you get ?
__________________
MySQL 5.1
Reply With Quote
  #9 (permalink)  
Old 07-14-06, 05:41
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
enable/disable probelm

hi

when i use this command:

SELECT `Host`, `User`, `Password` FROM `user`;

this is the error i am getting

ERROR 1046 (3D000): No database selected
Reply With Quote
  #10 (permalink)  
Old 07-14-06, 05:43
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
USE mysql;

And I hope you are using mysql command line - if not what client are you using ? In what are you executing queries ?
__________________
MySQL 5.1
Reply With Quote
  #11 (permalink)  
Old 07-14-06, 05:51
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
hi

yeah you are right i am useing MYSQL Command Prompt.

i tried with SQLYog also....

but no result.
thanks
Ramana
Reply With Quote
  #12 (permalink)  
Old 07-14-06, 05:56
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
Whats the result of DESCRIBE `user` ?
__________________
MySQL 5.1
Reply With Quote
  #13 (permalink)  
Old 07-14-06, 06:06
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
hi

COMMAND ESCRIBE `user`
this is the result

ERROR 1046 (3D000): No database selected

thanks
Reply With Quote
  #14 (permalink)  
Old 07-14-06, 06:28
anjanesh anjanesh is offline
Registered User
 
Join Date: Feb 2005
Location: Mumbai, India
Posts: 161
To select the database type
USE mysql;
__________________
MySQL 5.1
Reply With Quote
  #15 (permalink)  
Old 07-14-06, 06:42
ramana_ranga ramana_ranga is offline
Registered User
 
Join Date: Jul 2006
Posts: 11
enable/disable

hi

when i typed :
mysql> use mysql database;
Database changed

after that when i type

mysql> DESCRIBE `user`;
+-----------------------+-----------------------------------+------+-----+-----
---+-------+
| Field | Type | Null | Key | Defa
lt | Extra |
+-----------------------+-----------------------------------+------+-----+-----
---+-------+
| Host | char(60) | NO | PRI |
| |
| User | char(16) | NO | PRI |
| |
| Password | char(41) | NO | |
| |
| Select_priv | enum('N','Y') | NO | | N
| |
| Insert_priv | enum('N','Y') | NO | | N
| |
| Update_priv | enum('N','Y') | NO | | N
| |
| Delete_priv | enum('N','Y') | NO | | N
| |
| Create_priv | enum('N','Y') | NO | | N
| |
| Drop_priv | enum('N','Y') | NO | | N
| |
| Reload_priv | enum('N','Y') | NO | | N
| |
| Shutdown_priv | enum('N','Y') | NO | | N
| |
| Process_priv | enum('N','Y') | NO | | N
| |
| File_priv | enum('N','Y') | NO | | N
| |
| Grant_priv | enum('N','Y') | NO | | N
| |
| References_priv | enum('N','Y') | NO | | N
| |
| Index_priv | enum('N','Y') | NO | | N
| |
| Alter_priv | enum('N','Y') | NO | | N
| |
| Show_db_priv | enum('N','Y') | NO | | N
| |
| Super_priv | enum('N','Y') | NO | | N
| |
| Create_tmp_table_priv | enum('N','Y') | NO | | N
| |
| Lock_tables_priv | enum('N','Y') | NO | | N
| |
| Execute_priv | enum('N','Y') | NO | | N
| |
| Repl_slave_priv | enum('N','Y') | NO | | N
| |
| Repl_client_priv | enum('N','Y') | NO | | N
| |
| Create_view_priv | enum('N','Y') | NO | | N
| |
| Show_view_priv | enum('N','Y') | NO | | N
| |
| Create_routine_priv | enum('N','Y') | NO | | N
| |
| Alter_routine_priv | enum('N','Y') | NO | | N
| |
| Create_user_priv | enum('N','Y') | NO | | N
| |
| ssl_type | enum('','ANY','X509','SPECIFIED') | NO | |
| |
| ssl_cipher | blob | NO | |
| |
| x509_issuer | blob | NO | |
| |
| x509_subject | blob | NO | |
| |
| max_questions | int(11) unsigned | NO | | 0
| |
| max_updates | int(11) unsigned | NO | | 0
| |
| max_connections | int(11) unsigned | NO | | 0
| |
| max_user_connections | int(11) unsigned | NO | | 0
| |
+-----------------------+-----------------------------------+------+-----+-----
---+-------+
37 rows in set (0.00 sec)



this is the result.

thanks
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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
Trackbacks are On
Pingbacks are On
Refbacks are On