从Joomla导出数据! db并导入Ownlcoud db

时间:2016-08-29 21:41:12

标签: mysql joomla

我正在尝试从joomla MySQL数据库导出数据并将其导入到自己的MySQL数据库中。

的Joomla! db表是xxx_users,导出所需的列是: 用户名,密码。

Ownlcloud db表是xxx_users,导入所需的列是: uid(用户名),密码。

Owncloud密码加密与Joomla!略有不同,因为它有一个'1 |'密码的前缀,我不知道如何实现这一点。

我有导出和导入脚本,但需要一些工作。

这将与cron作业一起使用,如果用户存在于Owncloud数据库中,则会覆盖详细信息。

export.php

<?php
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName ='db1';
$mysqlUserName ='db1owner';
$mysqlHostName ='db1.mywebhost.net';
$mysqlExportPath ='db1backup.sql';

//DONT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command='mysqldump --opt -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p'     .$mysqlPassword .' ' .$mysqlDatabaseName .'
> ~/' .$mysqlExportPath;
exec($command,$output=array(),$worked);
switch($worked){
case 0:
echo 'Database <b>' .$mysqlDatabaseName .'</b> successfully exported to <b>~/' .$mysqlExportPath .'</b>';
break;
case 1:
echo 'There was a warning during the export of <b>' .$mysqlDatabaseName   .'</b> to <b>~/' .$mysqlExportPath .'</b>';
break;
case 2:
echo 'There was an error during export. Please check your values:<br/><br/>    <table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td>   </tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr>   <td>MySQL Password:</td><td><b>NOTSHOWN </b></td></tr><tr><td>MySQL Host Name:   </td><td><b>' .$mysqlHostName .'</b></td></tr></table>';
break;
}
?> 

import.php

<?php
//ENTER THE RELEVANT INFO BELOW
$mysqlDatabaseName ='db2';
$mysqlUserName ='db2owner';
$mysqlPassword ='Password';
$mysqlHostName ='db2.mywebhost.net';
$mysqlImportFilename ='db1backup.sql';

//DONT EDIT BELOW THIS LINE
//Export the database and output the status to the page
$command='mysql -h' .$mysqlHostName .' -u' .$mysqlUserName .' -p' .$mysqlPassword .' ' .$mysqlDatabaseName .' < ' .$mysqlImportFilename;
exec($command,$output=array(),$worked);
switch($worked){
case 0:
echo 'Import file <b>' .$mysqlImportFilename .'</b> successfully imported to     database <b>' .$mysqlDatabaseName .'</b>';
break;
case 1:
echo 'There was an error during import. Please make sure the import file is     saved in the same folder as this script and check your values:<br/><br/><table><tr><td>MySQL Database Name:</td><td><b>' .$mysqlDatabaseName .'</b></td></tr><tr><td>MySQL User Name:</td><td><b>' .$mysqlUserName .'</b></td></tr><tr><td>MySQL Password:</td><td><b>NOTSHOWN</b></td></tr><tr><td>MySQL Host Name:</td><td><b>' .$mysqlHostName .'</b></td></tr><tr><td>MySQL Import Filename:</td><td><b>' .$mysqlImportFilename .'</b></td></tr></table>';
break;
}
?> 

0 个答案:

没有答案