Archive: sql


sql
I am so curious to ask this question. I found this page in wiki of NSIS.

http://nsis.sourceforge.net/wiki/Exe...Server_scripts

There is a script which execute sql file in sql server 2000.But my question is how can I run a sql file in Mysql 4.0?? Is there any way to solve this problem?


You should be able to do it like this:

Find the mysql.exe client.
Execute it in a manner similar to this:

mysql -uusername -p < script.sql

The user will be asked to input his password. Appearantly, there's a way to use the -p switch to provide it on the command line, but I never could seem to get it to work.

You may need to specify the database name just before the <.

The alternative would be to require MyODBC installed and go through that - but you'll probably need to write a seperate program for this.


u can use a simple way out, create a .bat file and u can write the sql home directory path to that file. and that file also contained the name of sql query file. so the structure of bat file will look like:

set PATH=%PATH%;C:\mysql\bin

mysql --host=localhost --user=root < update_password.sql

u can execute the bat file using Exec, ExecWait and ExecShell using install and this will work fine.

i'm working with the same.;)


Originally posted by P_B

set PATH=%PATH%;C:\mysql\bin

mysql --host=localhost --user=root < update_password.sql

After "--user" can I put password?

if u need a password to login to dbase, example i've given was for setting the password of user root, because intially dbase user doesn't have the password set. so if ur dbase has password set then u need to write the password too. so it will look like :

mysql --host=localhost --user=root --password=root < update_password.sql


Yup.it's work.

But i have got a new problem.This line perfectly works for older version of Mysql like Mysql 4.0 or so on.
setpath=%PATH%;C:\mysql\bin

But when I work on Mysql 5.0, I can't set the path.I know it's Mysql related question but have you any idea about this?


MySql 5.0 is bit different from the older versions. It will set the env var Path of its own. so i dont think if u need to set it seperately.