LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 02-20-2006, 05:05 PM   #1
nazs
Member
 
Registered: Apr 2005
Posts: 57

Rep: Reputation: 15
Help with a delete user script


Hi All,
I need to delete around 30 users from multiple databases. I was hoping someone with experience writing scripts might be able to come up with something to speed up the process of deleting 1 user at a time. This is the command I use to delete a user. First I do this command:

mysql -u root -p datbase_name (enter)

I have to enter a mysql password.
Then I delete the user with this command:

delete from user where user='username'; (enter)

I would like to be able to paste a list of usernames in the script so it will go through the delete user line one at a time till the list is done.
If you need more information please let me know.

Thanks,
Nazs
 
Old 02-20-2006, 05:14 PM   #2
headrift
Member
 
Registered: Sep 2005
Distribution: Gentoo, Sabayon, Puppy, Arch
Posts: 128

Rep: Reputation: 25
You don't need a script as much as the right bit of SQL.

Code:
DELETE FROM table WHERE username IN (user1, user2, usern)
You'd still have to do some typing, but less than if you did it one line at a time.

If you have a flat file of usernames, you might be able to do something with perl or python (those would be my choices).
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
delete user pantera Fedora 9 09-20-2005 06:34 AM
how do I delete my user FlyingSolo General 3 04-13-2005 05:26 AM
Delete old files and folders Script? AsteX Linux - General 4 11-11-2004 06:26 PM
Script to Delete Old Mbox Mail granatica Linux - Software 2 10-06-2003 10:01 AM
Script on linux to delete certain files ForumKid Linux - General 2 06-22-2002 01:09 PM


All times are GMT -5. The time now is 04:15 PM.

Main Menu
 
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
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration