无法将数据库还原到本地 (xampp)
Cannot restore database to local (xampp)
我有一个 wordpress 网站,并备份了所有文件,包括数据库,所以我从 phpmyadmin 恢复数据库文件。
(抱歉我是 sql 和 mysql 的新手)
phpmyadmin 给我一个错误:
SQL query:
Table: wp_options
Approximate rows expected in table: 193
Delete any existing table wp_options
DROP TABLE IF EXISTS wp_options
MySQL said:
1046 - No database selected
Picture of error.
在顶部添加 "use" 命令到 select db:
USE [database name];
使用下面的查询并将结果设置为变量以检查 table 是否存在:
declare @ifExists int = 0;
set @ifExists = (SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = '[database name]'
AND table_name = '[table name]';)
然后使用@ifExists 来决定是否需要删除一个table:
if @ifExists > 0
begin
DROP TABLE [table name]
end
我有一个 wordpress 网站,并备份了所有文件,包括数据库,所以我从 phpmyadmin 恢复数据库文件。
(抱歉我是 sql 和 mysql 的新手)
phpmyadmin 给我一个错误:
SQL query:
Table:
wp_options
Approximate rows expected in table: 193
Delete any existing table
wp_options
DROP TABLE IF EXISTS
wp_options
MySQL said:
1046 - No database selected
Picture of error.
在顶部添加 "use" 命令到 select db:
USE [database name];
使用下面的查询并将结果设置为变量以检查 table 是否存在:
declare @ifExists int = 0;
set @ifExists = (SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = '[database name]'
AND table_name = '[table name]';)
然后使用@ifExists 来决定是否需要删除一个table:
if @ifExists > 0
begin
DROP TABLE [table name]
end