Home > Database > Mysql Tutorial > body text

mysql数据导出导入方法

WBOY
Release: 2016-06-07 17:51:09
Original
907 people have browsed it

我们先来看数据出办法,用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);

?>

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!