Xand3r Posted May 21, 2009 Posted May 21, 2009 (edited) I'm having some trouble using autoit to import a sql dump to a mysql server i used this If $user<>"" Then $user="-u"&$user If $pass<>"" Then $pass="-p"&$pass If $database<>"" Then $database="--database "&$database $_from = '< '&_name($_SQL_IMPORT_FILE) $ss=Run(@ScriptDir&"\mysql.exe"&StringFormat(" -v -v -v %s %s %s %s",$user,$pass,$database,$_from) , _path($_SQL_IMPORT_FILE),@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD) Func _path($path) Local $drive,$dir,$name,$ext $ss=_PathSplit($path,$drive,$dir,$name,$ext) Return $drive&$dir EndFunc Func _name($path) Local $drive,$dir,$name,$ext $ss=_PathSplit($path,$drive,$dir,$name,$ext) Return $name&$ext EndFunc but it dosen't work 1. it won't import the data 2. it will only print the mysql --hel any ideeas? thanks in advance Edited May 22, 2009 by Xand3r Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
weaponx Posted May 21, 2009 Posted May 21, 2009 These lines won't work at all... If $user<>"" Then $user="-u"&$user If $pass<>"" Then $pass="-p"&$pass Should be: If $user<>"" Then $user="-u " & $user If $pass<>"" Then $pass="-p " & $pass
Xand3r Posted May 21, 2009 Author Posted May 21, 2009 (edited) it works fine like that dude... i know that for a fact on linux and i tried it before i used it on windows too... that's not the problem in fact If $pass<>"" Then $pass="-p " & $pass won't work at all it's just gonna think that your password is the database name Edited May 21, 2009 by Xand3r Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
weaponx Posted May 21, 2009 Posted May 21, 2009 it works fine like that dude... i know that for a fact on linux and i tried it before i used it on windows too... that's not the problemin fact If $pass<>"" Then $pass="-p " & $pass won't work at all it's just gonna think that your password is the database name Well considering I don't know if $user and $pass have a leading space I can't really tell, but I do know this is invalid syntax...$user = "jsmith"$pass = "12345" If $user<>"" Then $user="-u"&$user If $pass<>"" Then $pass="-p"&$pass$user: "-ujsmith"$pass: "-p12345
Xand3r Posted May 21, 2009 Author Posted May 21, 2009 dude do you think i'm retarded?? or what?? get wamp (easy to install) and in a shell write this: mysql -uroot -Dmysql and you'll see that it works just fine then change the password of the root account to "test" and try theese: mysql -u root -p test -D mysql and mysql -uroot -ptest -Dmysql and this it what you will notice: the first will work just fine the second will ask you for you password (wtf it's already there right?) you input your password and it will complain about not finding the 'test' database... and the third one will work FINE my point is i do know what i am doing but for some reason the < somefile.sql only works from cmd??? if i run the command from cmd it will work just fine... if i run it with autoit i get the help if i run it from the run(#+r) help file(it dissapears very fast but you can see that it's not working) Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
Xand3r Posted May 22, 2009 Author Posted May 22, 2009 (edited) i solved it myself.. $ss=Run(@ScriptDir&"\mysql.exe"&StringFormat(" -v -v -v %s %s %s",$user,$pass,$database) , _path($_SQL_IMPORT_FILE),@SW_HIDE,$STDERR_CHILD + $STDOUT_CHILD + $STDIN_CHILD) StdinWrite($ss,FileRead($_SQL_IMPORT_FILE)) Edited May 22, 2009 by Xand3r Only two things are infinite, the universe and human stupidity, and i'm not sure about the former -Alber EinsteinPractice makes perfect! but nobody's perfect so why practice at all?http://forum.ambrozie.ro
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now