LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 08-14-2008, 04:03 PM   #1
jakev383
QmailToaster Developer
 
Registered: Dec 2005
Location: Burlington, NC
Distribution: CentOS, Voyage, Debian, Fedora
Posts: 220

Rep: Reputation: 31
Set mysql root password in script


This one has me banging my head.... I have a script that asks for input such as the mysql root password that a user wants to set on a new install and then performs these actions for them. I'm missing something in the variable expansion though. I ask for the mysql root password ($MYPW), and also get the hostname from the environment ($HNAME=`hostname`). I'm trying to set them like this:

Code:
echo "SET PASSWORD FOR 'root'@'localhost' = PASSWORD(\'$MYPW\');" | mysql -u root
echo "SET PASSWORD FOR 'root'@\'$HNAME\' = PASSWORD(\'$MYPW\');" | mysql -u root -p$MYPW
But that didn't work. Can someone see offhand what I've borked or a different way to accomplish this?
Thanks in advance!
 
Old 08-14-2008, 04:11 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
You don't need the \ in each of these.
 
  


Reply



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



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to set login and password and root password in suse 10.2 sirius57 SUSE / openSUSE 8 07-24-2007 09:51 AM
Cannot set root password zener Ubuntu 11 01-27-2007 12:40 PM
change Root Password even if the password in the grub is also set sheelnidhi Linux - General 6 08-30-2006 07:27 AM
Cannot Log into MySQL root password I just set... k41184 Linux - Software 3 07-18-2005 10:57 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration