The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Special Forums > UNIX and Linux Applications
.
google unix.com



UNIX and Linux Applications Discuss UNIX and Linux software applications. This includes SQL, Databases, Middleware, MOM, SOA, EDA, CEP, BI, BPM and similar topics.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do I make dynamic parameter names? Or get the value of a parameter evaluated twi Awanka Shell Programming and Scripting 2 04-19-2007 09:37 PM
How to delete the files from local host to remote host krishna176 SUN Solaris 3 03-24-2007 04:48 PM
Password parameter wweldin UNIX for Dummies Questions & Answers 1 06-28-2006 10:39 AM
host alias not working: host not found FunnyCats UNIX for Advanced & Expert Users 4 05-13-2005 04:36 PM
QNX host cannot ping SCO host, vice versa gavon IP Networking 2 08-20-2001 08:57 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-16-2008
ankimo ankimo is offline
Registered User
  
 

Join Date: Sep 2008
Posts: 23
set mysql password with host parameter

hi, linux gurus...

i'm trying to write a script in ksh called ResetPass that allows a user to change mysql passwords. the script accepts user, password and host like this: ResetPass <user> <password> <host>. here's the code:


*****************************************************
mysql -BCNnqs --disable-pager -u system -pmanager << EOJ
use mysql;

set @user = '${1-.}';
set @pass = '${2-.}';
set @host = '${3-.}';

update user set password=password(@pass) where user=@user and host=@host;
flush privileges;

quit

EOJ
*****************************************************


when i only use this bit...

update user set password=password(@pass) where user=@user;

... it works. but when i add the part, "and host=@host", it no longer does. there's something clearly wrong with my syntax but i'm not sure what. the mysql manual itself, says to use this form:


*****************************************************
UPDATE mysql.user SET Password=PASSWORD('newpass')
WHERE User='bob' AND Host='%.loc.gov';
FLUSH PRIVILEGES;

*****************************************************

if anyone can see what i'm doing wrong, i would appreciate your advice. thanks!

ankimo
  #2 (permalink)  
Old 09-16-2008
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,847
I believe that with the wild card % you should use the like operator:

Code:
update user set password=password(@pass) where user=@user and host like @host;
You should be careful, of course, with the matched records
Closed Thread

Bookmarks

Tags
host, ksh, mysql, password, set

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 11:40 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0