Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/12/2011, 13:23
kerwinamaro
 
Fecha de Ingreso: diciembre-2011
Mensajes: 4
Antigüedad: 12 años, 4 meses
Puntos: 0
Exclamación Como Respaldar mi Base de Datos Mysql con PHP

Estoy tratando de hacer un respaldo de mi base de datos a traves de php en un formulario y con un boton submit que vi en este foro pero cuando lo ejecuto me da el siguiente error:

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\wamp\www\Base de Datos\respaldo.php on line 4
Error connecting to DDBB.

Anexo el codigo proporcionado por el compañero ZiTAL de este Foro


<?php
function Connect($host,$user,$passwd)
{
if(!($link=mysql_connect($host,$user,$passwd)))
{
echo "Error connecting to DDBB.";
exit();
}
return $link;
}
$link=Connect('localhost','root','root');
//
if($_POST['submit'])
{
$db=$_POST['db'];
$output=shell_exec("d:\apps\mysql-5.0.45-win32\bin\mysqldump.exe -u root -proot ".$db); // ejemplo windows
//$output=shell_exec("/usr/bin/mysqldump -u root -proot ".$db); // ejemplo linux
//
if(trim($output)==NULL)
{
echo "Error creando el backup de la DB: ".$db;
exit();
}
header('Content-type: text/plain');
header('Content-Disposition: attachment; filename="'.$db.'.sql"');
echo $output;
exit();
}
$select="show databases";
$select=mysql_query($select);
?>
<html>
<head>
</head>
<body>
<form action="" method="post">
<select name="db">
<?php
while($row = mysql_fetch_row($select))
{
?>
<option value="<?php echo $row[0]; ?>"><?php echo $row[0]; ?></option>
<?php
}
?>
</select>
<input type="submit" name="submit" value="Crear backup" />
</form>
</body>
</html>



Si alguien me puede ayudar seria de mucha ayuda