set mysql password with host parameter


 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications set mysql password with host parameter
# 1  
Old 09-16-2008
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  
Old 09-16-2008
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 Smilie
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Can't set parameter to lynx properly

My intention is to go through list of addresses and call google geocode api for each of them. I am using lynx for this, but somehow I can't supply the parameters to it in a proper way. To show that my parameters are OK I just hardcoded one address in my script and put it in my input file, and... (2 Replies)
Discussion started by: migurus
2 Replies

2. Shell Programming and Scripting

Set variable to path that does not exist on local host

Can anyone suggest a workaround zone_5.org='/qaz/qwe/path/tns.osn' output /home/bingo/XXX_script.sh: line 180: zone_5.org=/qaz/qwe/path/tns.osn: no parent The path does not exist on the local machine, the allocation used to work till the server was upgraded. Red Hat Enterprise Linux... (2 Replies)
Discussion started by: squrcles
2 Replies

3. Shell Programming and Scripting

Dot operator and space, Parameter not set

Hi, i have this script setenv.sh if then echo "is empty" fi echo "done" The following is the result when i run the script from command without and with a dot and space operator $ setenv.sh is empty done $ . setenv.sh sh: VAR_1: Parameter not set. $ It's our standard to run... (5 Replies)
Discussion started by: ysrini
5 Replies

4. Programming

Set host default gateway in C program.

Hello everybody, I'm having troubles on setting the default gateway address (and other addresses, such as netmask, or ip) of the host running a C program. I know it has to be with ioctl, but don't know how to do it. Could somebody give me an example on how to set the default gateway address of... (4 Replies)
Discussion started by: semash!
4 Replies

5. Web Development

Error when trying to set Admin password in MySQL

I'm trying to set an admin password for MySQL using the following command: $ /usr/local/mysql/bin/mysqladmin -u root -p new_password But, I get the following error message? /usr/local/mysql/bin/mysqladmin: connect to server at 'localhost' failed error: 'Access denied for user... (2 Replies)
Discussion started by: Abder-Rahman
2 Replies

6. Shell Programming and Scripting

rsh login to host with password

Hello, iḿ rather new to writing scripts in UNIX so i thought this would be a good start. I need to write a script that can login to different hosts in a standalone network. That means there are no connection to Internet etc. I need to collect some data on the hosts, and they have different... (11 Replies)
Discussion started by: topy
11 Replies

7. Shell Programming and Scripting

? parameter in mysql query

I am debugging some code and came across ? in the WHERE cause in a mysql query. Is this possible and what situations would this be used? SELECT ip, count FROM table WHERE domain=? thanks & regards (2 Replies)
Discussion started by: hazno
2 Replies

8. UNIX for Dummies Questions & Answers

Password parameter

What does the UNIX password parameter "Password: Days till inactive" mean? Thanks. (1 Reply)
Discussion started by: wweldin
1 Replies

9. Shell Programming and Scripting

ksh: dbfFILe: parameter not set

Having the following message returned: FIND REDLOG FILES..... ksh: dbfFILe: parameter not set When I attempt to perform the script below....#!/bin/ksh . $HOME/.profile # Initial Script Prerequisites ORACLE_SID=MDirect ; export ORACLE_SID REDOLOGDIR=$ARCLOGDEST ; export REDOLOGDIR... (2 Replies)
Discussion started by: Cameron
2 Replies

10. UNIX for Dummies Questions & Answers

DEBUG_PROG and opts: parameter not set

I am using a Sun Ultra 30 with 250MG of RAM and 9GIG of hard drive. I connect to the machine via Exceed 6 and have the Oracle8i for Solaris in the cdrom drive. I have read and complied with Oracle's instruction in preparation to installing Oracle. Since I don't have enough space to cp the content... (1 Reply)
Discussion started by: Alexxx14
1 Replies
Login or Register to Ask a Question