ERROR 1049 (42000): Unknown database, localized Wordpress database - mysql

I'm moving my wordpress website to local for testing purpose.
I encountered the error below when I'm trying to import the .sql that I export from CPanel PHPMyadmin into local MYSQL Workbench.
FYI, I'm using MYSQL Workbench 6.0 and MYSQL Administrator 1.2.17
15:08:07 Restoring C:\Users\abc\Desktop\db.sql
Running: mysql.exe --defaults-extra-file="c:\users\abc\appdata\local\temp\3\tmpdemide.cnf" --host=localhost --user=root --port=3307 --default-character-set=utf8 --comments --database=db < "C:\\Users\\abc\\Desktop\\db.sql"
ERROR 1049 (42000): Unknown database 'db'
Operation failed with exitcode 1
15:08:08 Import of C:\Users\abc\Desktop\db.sql has finished with 1 errors

Apparently the export was done without specifying a database (schema), so you have to create it manually first before you can import the dump. MySQL Workbench allows to import a dump to a different (including a new) schema. You can specify this on the import page:

You looks like you have to create a database first
CREATE DATABASE db;
and then import your sql file.

Related

import mysql data dump to Maria DB

I am trying to import mysql data dump to Maria DB with below command
mysql -u root -p --one-database new_db < data_dump.sql;
But I am getting below error
ERROR 1064 (42000): You have an error in your SQL syntax; check the
manual that corresponds to your MariaDB server version for the right
syntax to use near 'mysql -u root -p --one-database zapcheck <
zapcheck.sql' at line 1
I tried different combinations but nothing worked. Its not even telling what's the issue.
Please let me know the issue here or is there any other way I can import?
You can try the command below to import the file:
Note: Open the terminal where dump.sql is located
After opening the terminal:
//Skip this process if you have already created a database.
Mysql> create database newdb;
// Using the new created database
Mysql> use newdb;
// Importing the dump.sql file to newdb database
Mysql> source dump.sql

Import/Restore MySQL database?

I have 2 different dumps from a prev setup(MySQL 5.xx). The first one is a self-contained file on about 250 MB, the other is a folder with 317 SQL files. Both is dumps from the same setup, just in different formats.
Now I need to restore one of them in the new MySQL 8 setup.
The folder dump contains a total of 10 schemas including sys. The MySQL 8 is just created so there is only a sys schema.
When I run the Import I just get a lot of errors like this:
10:09:24 Restoring myvideos93 (streamdetails) Running: mysql.exe
--defaults-file="c:\users\jimmy\appdata\local\temp\tmpk7oihn.cnf" --protocol=tcp --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments --database=myvideos93 < "F:\20180605
Backup\Documents\dumps\Dump20180605\myvideos93_streamdetails.sql"
ERROR 1049 (42000): Unknown database 'myvideos93'
Operation failed with exitcode 1
I'm doing this from MySQL Workbench on Windows 10 x64.
How to solve it?
Okay, so I hade to create each schema manually, but that was not enouth. I also hade to run the import 3 times until I only got 1 minor error. MySQL Windows components are still surprisingly unstable.

Error 1305 when importing sql dump into mySQL Workbench

I am importing a sql dump file into MySQL workbench and keep getting the error below. Does this mean the rest of the file/records did not import or only the xxx.getRates portion did not?
Will I be missing records from it?
Does anyone know what might be causing this?
01:29:31 Restoring D:\Projects\CustomerName\Customer Files\xxx-2016-Oct-03.sql
Running: mysql.exe --defaults-file="c:\users\admini~1\appdata\local\temp\2\tmpru2fjn.cnf" --protocol=tcp --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments --database=xxx < "D:\Projects\CustomerName\Customer Files\xxx-2016-Oct-03.sql
ERROR 1305 (42000) at line 33522: FUNCTION xxx.getRates does not exist
Operation failed with exitcode 1
01:34:29 Import of D:\Projects\CustomerName\Customer Files\xxx-2016-Oct-03.sql has finished with 1 errors
When using mysqldump, you must explicitly ask for Stored routines to be dumped. The option is --routines if you are running it manually. If you are running it through some app (Workbench), then look for its mechanism:
[ ] Dump Stored Procedures and Functions
[ ] Dump Events
[ ] Dump Triggers

MYSQL importing dump completed with errors

when I try to import my exported dump file (specifically my database/schema) to other computer, I got this error;
D:\CAPSTONE SYSTEM\MyDataBaseCAPSTONE\Dump20150922\schm_capstonesystem_routines.sql does not contain schema/table information
16:58:55 Restoring schm_capstonesystem (employee_entry)
Running: mysql.exe --defaults-file="c:\users\kc\appdata\local\temp\tmpnowdu_.cnf" --protocol=tcp --host=localhost --user=root --port=3306 --default-character-set=utf8 --comments --database=schm_capstonesystem < "D:\CAPSTONE SYSTEM\MyDataBaseCAPSTONE\Dump20150922\schm_capstonesystem_employee_entry.sql"
ERROR 1049 (42000): Unknown database 'schm_capstonesystem'
Operation failed with exitcode 1
Please help~! :-(
The error is Unknown database. You have to create the database 'schm_capstonesystem' first.
And then run the import of your dump.
In case you don't know how to create the schema as in the answer above:
right Click the left pane under Schema in SQL, click create schema,enter a name for the schema (preferably the same as the db your importing) click apply. Then do the import

ERROR When Importing SQL File into MySQL Database

I'm trying to import an SQL file I have on a server and put it into the database. But I keep failing and it gives me an error.
This is the command and error I get:
try logging into mysql first
mysql -p username
enter your password:
mysql> source yourfile.sql;