Restaure a MySQL DataBase

Hello,

PhpMyadmin download files before run the dump file.
If the dump file is to big, phpmyadmin give a timeout

For example I have a user with a dump file = 30MB

To restore his file I did that :

su -

usermod -s /bin/bash user1

su - user1

mysql --user=dbuser --password=dbpasswd hisdatabasename < file.dump (or file.sql)

exit

usermod -s /sbin/nologin user1

It works, but I don’t want do that for all new users whom have a database to restore with files > 10-15 Mo

So, I was wondering if there is the possibility to create a script that would do that and give this one to user.

It will ask for : User, databasename, userdb, passwddb, filedump
and then run what I did manually

I could do this with the system() in php

It could be a new SW fonctiunality ?

Does somebody already did something like that ?
Do you have another solutions ?

Thanks

Pascal

Hello,

In fact I’m pretty sure I don’t need to do the su - and su - userxx and usermod -s

I could do a Php form asking for :

  • databasename
  • User database
  • Passwd for user database
  • location of the dump or .sql file to restore

For the location, I’ll need to define the home directory for that user. (/home/domaine/…)

How do you define the directory name for new user. I kown you use the domaine name without chars as - but what is the exact rules ?

I’d like to ask to user to input in the form their domain name, like this I could define the home directory and *cat the location of the files.

for example if the user enter as location /mydomaine.com/mysqlbackup/filetorestore.dump and they enter my-domaine.com I’ll know that the full path of the file will be /home/mydomain/mydomaine.com/mysqlbackup/filetorestore.dump

Could you please give me the rules for the definition of the new unix user name in SW

Thanks

well I’ll try without your rules, and i’ll see.

nobody know ? any interworx staff user ?

Username

Pascal,

For the username, we use the first 8 characters of the domain name, omitting non-word characters (hyphens, dots, etc.). For example, my-domain.com becomes mydomain. If the domain name is less than 8 characters long, excluding non-word characters, then the username is the entire domain name without any non-word characters. For example, abc.com becomes abccom.

Hope that helps.

Bojan

Ok thanks Bojan

Do you have an other idea to perform what I’d like to do or do you think it’s the better way ?

Do you think I need to perform a su - and su user or not ?

For the location, I’ll need to define the home directory for that user. (/home/domaine/…)

Is there an other solution to define automaticly the entire path of the user’s home directory than recalculate in php the account user from the domain name ?

Thanks

Do you think I need to perform a su - and su user or not ?

For mysql you don’t need to su Pascal.

Before you do any programming Pascal I’d try simply raising the memory and post limits in iworx’s PHP instance (in the /home/interworx/etc/php.ini file). Since no matter what you will do it will simply be recreating what phpmyadmin is doing I’d start there before going into your own solution.

Is there any error when their import fails?

Chris

Hi

thanks Chris,

Is there any error when their import fails?

there is only a time out error. Apparently if the download takes more than 30s

But generaly, I find that phpmyqdmin is very slow, even if you insert records manually directly from it.

Before you do any programming Pascal I’d try simply raising the memory and post limits in iworx’s PHP instance (in the /home/interworx/etc/php.ini file).

Ok yet I have these data :
memory_limit = 128M
post_max_size = 128M

I’m setting them up to
memory_limit = 256M
post_max_size = 256M

Hope this will not decrease the general performance :slight_smile:

Thanks Chris
Pascal

there is only a time out error. Apparently if the download takes more than 30s

I’d also check out the ‘max_execution_time’ variable and make sure it’s high, a few minutes or more.

Chris

yep I’ve checked it.

It set at 900 so 15mn it should be enough :slight_smile: