![](/img/trans.png)
[英]Not able to import any sql file using command line in windows xampp
[英]Import from sql file without command line
使用PHP,我有一个sql文件,我想导入到数据库中。 不幸的是,我不能使用任何命令( php exec
)。
我该怎么办(没有phpMyAdmin和co)?
谢谢。
或仅使用PHP。
请注意,SQL文件应包含USE database
语句,因为mysqli_connect不使用默认数据库。
SQL文件代码
USE stackoverflow;
CREATE TABLE test() (
id int
);
PHP代码
<?php
$fileContentsString = file_get_contents([path_to_sql_file]);
$connection = mysqli_connect("127.0.0.1", "username", "password");
mysqli_multi_query($connection, $fileContentsString);
?>
更好地使用MySQL Workbench。 MySQL Workbench是一个可视化的数据库设计工具,它将SQL开发,管理,数据库设计,创建和维护集成到用于MySQL数据库系统的单个集成开发环境中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.