Good Morning,
sorry for my frequently question, but how I can delete an sql users from shell scripts in an one command?
THanks for the support
Good Morning,
sorry for my frequently question, but how I can delete an sql users from shell scripts in an one command?
THanks for the support
There is no need to write a shell script. All you have to do is run one command at mysql> prompt:
However, DROP USER will not automatically delete any database objects that the user created. This applies to tables, views, stored routines, and triggers etc all.Code:DROP USER userName;
All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]
yes but i want insert the command into bash scripts because it is an part of an multiple operation
if i want make this into only line i can use this?
I have tryed but it seems not work... where i wrong?Code:mysql -uroot -ppassword > DROP USER users;
Last edited by nixcraft; 2nd October 2009 at 06:24 PM. Reason: code tags
Try
Code:#!/bin/bash ... ... # set username userName="foo" mysql -u username -p'Password' -e "DROP USER $userName;" ... ..
All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]
Hi,
i have tryed but this is the error
Code:ERROR 1396 (HY000) at line 1: Operation DROP USER failed for 'foo'@'%'
You need to set userName varaible with actual username. If you want to delete a user called vivek, it must be set to vivek:
Also, you need to specify @localhost i.e.:Code:userName="vivek"
To view grants see:Code:mysql -u username -p'Password' -e "DROP USER $userName@localhost;"
HTHCode:mysql -u root -p'password' mysql -e "SHOW GRANTS for $userName@localhost;"
All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]
you are the bestit work
thanks![]()
There are currently 1 users browsing this thread. (0 members and 1 guests)