简体   繁体   中英

Cannot restore database to local (xampp)

I have a wordpress webiste, and backed up all files including database, so from phpmyadmin im restoring the database file.

(sorry im new to sql and mysql)

And phpmyadmin giving me an error :

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.

Add "use" command on the top to select db:

USE [database name];

Use the query below and set the result to a variable to check if table exists:

declare @ifExists int = 0;
set @ifExists = (SELECT COUNT(*)
                 FROM information_schema.tables 
                 WHERE table_schema = '[database name]' 
                 AND table_name = '[table name]';)

Then use @ifExists to decide whether you need to drop a table or not:

if @ifExists > 0
begin
   DROP TABLE [table name]
end

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM