Welcome Guest. Please Login or Register  


You are here: Index > Softaculous Auto Installer > General Support > Topic : Database created but not importing SQL



Threaded Mode | Print  

 Database created but not importing SQL (8 Replies, Read 4207 times)
LeonardChallis
Group: Member
Post Group: Newbie
Posts: 3
Status:
I've created a custom package and it is running nicely, apart from the fact that the database isn't being setup correctly.

In my install.php I have the following:

PHP Code

 $sqlPath '/tmp/' $software['softname'] . '.sql';
sdb_export('localhost''some_db''password''someuser'$sqlPath);
sdb_import($sqlPath); 



After the installation runs, the SQL dump file appears in the /tmp folder correctly. However, the sub_import() function isn't running correctly.

I don't see any errors, and manually importing the SQL to the same database from the dump file works fine. I may be looking in the wrong place but my /var/softaculous/error_log is empty and I can't find anything in other logs I've seen - maybe I'm missing the correct one?

If someone can suggest something to try next I'd appreciate it.
IP: --   

Database created but not importing SQL
Brijesh
Group: Softaculous Team
Post Group: Super Member
Posts: 5640
Status:
Hi,

sdb_import() takes the parameter as the filename and the file should be available at :
/var/softaculous/SOFTNAME

You just need to pass the filename, you cannot pass the full path to the SQL file.

Or you can read that SQL file and then execute the query using sdb_query() function :
PHP Code

 sdb_query($data$__settings['softdbhost'], $__settings['softdbuser'], $__settings['softdbpass'], $__settings['softdb']); 



-----------------------
Webuzo - Multi User Hosting Control Panel
AMPPS - Best WordPress/PHP/MySQL development tool
IP: --   

Database created but not importing SQL
LeonardChallis
Group: Member
Post Group: Newbie
Posts: 3
Status:
Hey Brijesh, thanks so much for replying!

In the documentation I read this:

sdb_import($parameter1) - This function is used to execute the database queries.
1st Parameter (required) = String $parameter1 is the Absolute path of the file which contains the database queries to be executed.

From what you've said, does this mean the documentation is wrong, and it's actually the relative path from /var/softaculous/softname?

If so, and presuming I want to dump a database first, how would I do this? I have tried doing something like this:

PHP Code

 sdb_export('localhost''some_db''password''someuser'$software['soft name'] . '.sql');
sdb_import($software['softname'] . '.sql'); 



But that doesn't work. I presume this is because of permissions? But I did a touch mysoftname.sql and chown myuser:myuser mysoftname.sql and re-ran installing the package but that didn't work.

As noted in my first post, it works if I try write to /tmp.

So, if I want to dump a database and place it in the package directory then import it, what's the correct way to go about it please?

Kind regards for your help!
IP: --   

Database created but not importing SQL
Brijesh
Group: Softaculous Team
Post Group: Super Member
Posts: 5640
Status:
Hi,

It looks like the documentation was incorrect for the sdb_import() function. I have updated it :
http://www.softaculous.com/docs/Making_Custom_Package#Explanation_of_Important_functions

To achieve your purpose you can use the following code :
PHP Code

 $sqlPath '/tmp/' $software['softname'] . '.sql';
sdb_export('localhost''some_db''password''someuser'$sqlPath);

$queries sfile($sqlPath);
sdb_query($queries'localhost''someuser''password''some_db'); 



Edited by Brijesh : November 2, 2015, 10:01 am

-----------------------
Webuzo - Multi User Hosting Control Panel
AMPPS - Best WordPress/PHP/MySQL development tool
IP: --   

Database created but not importing SQL
LeonardChallis
Group: Member
Post Group: Newbie
Posts: 3
Status:
Thanks again, that makes sense.

Did you mean to write sdb_query for the last line of PHP there?
IP: --   

Database created but not importing SQL
Brijesh
Group: Softaculous Team
Post Group: Super Member
Posts: 5640
Status:
Hi,

Yes it should be sdb_query()

I have edited the post.

-----------------------
Webuzo - Multi User Hosting Control Panel
AMPPS - Best WordPress/PHP/MySQL development tool
IP: --   

Database created but not importing SQL
purjayadi
Group: Member
Post Group: Newbie
Posts: 2
Status:
i have some issue about this, i have already try this

PHP Code

 $sqlPath '/tmp/' $software['cust'] . '.sql'
    
sdb_export('[[softdbhost]]''[[softdb]]''[[softdbpass]]''[[softdbuser]]'$sqlPath); 
    
    
$queries sfile($sqlPath); 
    
sdb_query($sqlPath'[[softdbhost]]''[[softdbuser]]''[[softdbpass]]''[[softdb]]'); 



but not work
IP: --   

Database created but not importing SQL
Brijesh
Group: Softaculous Team
Post Group: Super Member
Posts: 5640
Status:
Hi,

As per our discussion over email you have managed to get this working.

Let us know if you still face any issues.

-----------------------
Webuzo - Multi User Hosting Control Panel
AMPPS - Best WordPress/PHP/MySQL development tool
IP: --   

Database created but not importing SQL
purjayadi
Group: Member
Post Group: Newbie
Posts: 2
Status:
solved
Quote From : Brijesh July 19, 2019, 9:05 am
Hi,

As per our discussion over email you have managed to get this working.

Let us know if you still face any issues.
IP: --   

« Previous    Next »

Threaded Mode | Print  



Jump To :


Users viewing this topic
1 guests, 0 users.


All times are GMT. The time now is March 28, 2024, 9:10 pm.

  Powered By AEF 1.0.8 © 2007-2008 Electron Inc.Queries: 11  |  Page Created In:0.033