Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL SOURCE Error

Tags:

php

mysql

I have an issue with the MySQL SOURCE command. I am getting the following error:

1064: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SOURCE /var/www/apps/modx_install.sql' at line 1

The query I am executing is as follows:

mysql_query('SOURCE /var/www/apps/modx_install.sql;')

I was wondering what I was doing wrong here as I have read from several sources that this is the correct syntax.

Thanks

like image 245
Tom Hallam Avatar asked Feb 26 '23 09:02

Tom Hallam


1 Answers

it seems your MySQL-Server doesn't know the source command.

If you have shell access you could use

mysql --user=$user --password=$password $database < $file

You can try the same from within PHP

shell( "mysql --user=$user --password=$password $database < $file" );

Cheers.
haggi

like image 162
haggi Avatar answered Feb 28 '23 23:02

haggi