Jump to content

Recommended Posts

Posted

Hi All,

 

Have a server setup which is running phpmyadmin 2.11.10 and MySql Server 4.1.22.

 

Stored on the local drive there is a SQL Query that I want to run. I can run this manually by "importing" the SQL Query, or copying and pasting it into the Query window for the particular database. (Called LoginTrackerDatabase).

 

What I want to do, is set up a schedule so this runs everyday. Can this be done through windows task scheduler?

 

Thanks in advance for all replies.

 

Regards

 

Tom

Posted
Hi All,

 

Have a server setup which is running phpmyadmin 2.11.10 and MySql Server 4.1.22.

 

Stored on the local drive there is a SQL Query that I want to run. I can run this manually by "importing" the SQL Query, or copying and pasting it into the Query window for the particular database. (Called LoginTrackerDatabase).

 

What I want to do, is set up a schedule so this runs everyday. Can this be done through windows task scheduler?

 

Thanks in advance for all replies.

 

Regards

 

Tom

 

I think you'd need to edit it to a sort of batch file which loads the MySQL command prompt and imports the query file that way. Then this batch can be easily set to run using Scheduled Tasks.

 

Something like this might work if you save it to a batch file and run. Change the details for yours, and make sure the location to mysql.exe is correct (I use WAMP in a test environment):

 

C:\wamp\bin\mysql\mysql5.1.33\bin\mysql -uUSER -PASSWORD DATABASENAME < SQLFILE.sql

 

Another method would be to write the SQL query in a PHP file, stick it on the www area and run it.

Posted
I think you'd need to edit it to a sort of batch file which loads the MySQL command prompt and imports the query file that way. Then this batch can be easily set to run using Scheduled Tasks.

 

Something like this might work if you save it to a batch file and run. Change the details for yours, and make sure the location to mysql.exe is correct (I use WAMP in a test environment):

 

C:\wamp\bin\mysql\mysql5.1.33\bin\mysql -uUSER -PASSWORD DATABASENAME < SQLFILE.sql

 

Another method would be to write the SQL query in a PHP file, stick it on the www area and run it.

 

I am trying to do the above with this piece of code:

 

C:\Program Files\MySQL\MySQL Server 4.1\bin\mysql.exe -u MYUSERNAME -p MYPASSWORD logintracker < logintracker.sql

 

However I get an error:

 

"The system cannot find the spercified file". Any ideas? The logintracker.sql file is stored in the same directory as the mysql.exe (C:\Program Files\MySQL\MySQL Server 4.1\bin\logintracker.sql).

 

Kind Regards

 

Tom

Posted
I am trying to do the above with this piece of code:

 

C:\Program Files\MySQL\MySQL Server 4.1\bin\mysql.exe -u MYUSERNAME -p MYPASSWORD logintracker < logintracker.sql

However I get an error:

 

"The system cannot find the spercified file". Any ideas? The logintracker.sql file is stored in the same directory as the mysql.exe (C:\Program Files\MySQL\MySQL Server 4.1\bin\logintracker.sql).

 

Kind Regards

 

Tom

 

You need to put the full path, as logintracker.sql won't be in the same directory as your MySQL exe.

 

Something like:

 

C:\Dir\Dir2\logintracker.sql

  • Thanks 1
Posted (edited)

Thanks for all help so far. I now have the following code:

 

"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysql.exe" -u --root --password=MYPASSWORD logintracker < C:\Inetpub\wwwroot\logintracker\logintracker\logintracker.sql

 

Telling me there is an error with the username and password syntax. In addition to this, do I need to put " " around the dir for the sql script?

 

Regards

 

Tom

Edited by T_Noble
Posted

I think it's the -- before root that is doing it

 

"C:\Program Files\MySQL\MySQL Server 4.1\bin\mysql.exe" -u root --password=MYPASSWORD logintracker < C:\Inetpub\wwwroot\logintracker\logintracker\logintracker.sql

 

You only need those quotes where there are spaces in the path.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...