Home >Database >Mysql Tutorial >mysql数据导出导入方法

mysql数据导出导入方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-07 17:51:09970browse

我们先来看数据出办法,用mysql自带的命令行完成导入导出的工作,如下,还有一种是利用了php导入.sql文件哦。

假定 用户名和密码为 root xxx,为test

导入sql

 代码如下 复制代码

mysql -hlocalhost -uroot -pxxx test

导出sql

 代码如下 复制代码

mysqldump -hlocalhost -uroot -pxxx database > xxx.sql

把.sql利用导入到mysql数据库

 代码如下 复制代码

$conn=mysql_connect(“localhost”,”root”,”password”);//指定数据库连接参数

function mysql_import($file,$database)//导入的函数,参数为SQL文件路径和导入的库名。

{

mysql__db($database);

mysql_query(“source ‘”.$file.”‘;”);

echo “导入”.$file.”文件到”.$database.”数据库完毕”;

}

mysql_close($conn);

?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn