Home > php教程 > php手册 > php导入.sql到数据库的方法

php导入.sql到数据库的方法

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-26 15:22:12
Original
952 people have browsed it

以前我们都是利用phpmyadmin或在dos下进行.sql文件的导入,今天我们来看看在php下同样可以实现把.sql文件导入到mysql数据库中,代码如下:

<?php 
$conn=mysql_connect("localhost","root","password");//指定数据库连接参数function mysql_import($file,$database)// 导入的函数,参数为SQL文件路径和导入的库名。 
{ 
    mysql_select_db($database); 
    //开源代码phprm.com 
    mysql_query("source &#39;".$file."&#39;;"); 
    echo "导入".$file."文件到".$database."数据库完毕"; 
} 
mysql_close($conn);
Copy after login


本文地址:

转载随意,但请附上文章地址:-)

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template