Error when uploading MySQL database to phpMyAdmin [duplicate] - mysql

This question already has answers here:
phpMyAdmin "No database selected" MySQL
(7 answers)
Closed 4 years ago.
I apologize if this is simple. This seems to be a somewhat common error.
I'm trying to upload the MySQP database to phpMyAdmin and am getting the following error message. From what I read on other posts, it's probably as simple as a comma, but I can't figure it out. Any help is much appreciated!
SQL query:
-- Table structure for table `wp_eaet_commentmeta`
--
CREATE TABLE IF NOT EXISTS `wp_eaet_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
MySQL said:
1046 - No database selected

As the error says
MySQL said:
1046 - No database selected
Select a database first from list of the databases in phpmyadmin then upload

Related

No database selected when import the script

I created a script using MySqlWorkbench, at the top of the script there is this:
CREATE SCHEMA IF NOT EXISTS `contacts` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
USE `contacts` ;
when I import this script in PhpMyAdmin, I get:
SQL query:
CREATE TABLE `contact` (
`id` int(11) NOT NULL,
`name` varchar(45) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
MySQL said: Documentation
1046 - No database selected
Why the schema contacts isn't creating a new database?
Use CREATE TABLE contacts.contact
(not allowed to comment yet, so forced to use answer.)

mysql - 1054 Unknown column in field list

I have looked on stackoverflow and the mysql and Plantmysql forums
Nobody has quite been able to answer this.
Steps
I created a CSV from an Excel file
Imported using the Table Data Import Wizard in MySQL
I am able to run
SELECT * FROM apporteur_mapping_table;
However I get Error Code 1054 when I run
SELECT broker_code FROM apporteur_mapping_table;
Field type is VARCHAR(20)
Update #2 - output from SHOW Create Table
CREATE TABLE `apporteur_mapping_table` (
`broker_code` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL,
`broker_name` text COLLATE utf8_unicode_ci,
`date_de_creation_de_code` text COLLATE utf8_unicode_ci,
`commercial_contact_name` text COLLATE utf8_unicode_ci,
`id` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1690 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
3 Resolved
I seem to have been able to resolve it by Creating the table in code from scratch. It seems using the Table Data Import Wizard in mysql caused the data to have some interpretation
I am using MySQL Workbench 6.3 on Windows 10
Annotation can be found here
Link to CSV source here
Anyone able to help?

#1050 - Table 'wp_commentmeta' already exists

Error
SQL query:
CREATE TABLE `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci,
PRIMARY KEY (`meta_id`),
KEY `comment_id` (`comment_id`),
KEY `meta_key` (`meta_key`(191))
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
MySQL said: Documentation
#1050 - Table 'wp_commentmeta' already exists
I came across this issue and found that even if you drop the wp_commentmeta table, you are likely to have issues with other tables like wp_comments, wp_links etc.
Hence, the solution is just to drop the whole database, re-create a fresh one and restore to that. To do this, login to mysql:
mysql -u databaseuser -p
and then run the following command on your database:
drop database wordpress_database;
create database wordpress_database;
quit;
I had a similar issue and had to drop all the tables. Not recommended for the faint of heart. Make sure you have at least two different types of backups.
The error you are getting is pretty self explanatory!
You may think about executing the following SQL-Statement:
DROP TABLE wp_commentmeta;

Importing a MySQL database

Trying to import a MySQL database using PHP-Admin. When I try to import the file backed-up by my host, I get this error message:
SQL query:
DROP TABLE IF EXISTS `wp_commentmeta`
MySQL said: Documentation
#1046 - No database selected
I have also tried to export the database myself, then trying to import that specific file. When I do that, however, I get a completely different error message:
SQL query:
CREATE TABLE IF NOT EXISTS `wp_commentmeta` (
`meta_id` bigint(20) unsigned NOT NULL,
`comment_id` bigint(20) unsigned NOT NULL DEFAULT '0',
`meta_key` varchar(255) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`meta_value` longtext COLLATE utf8mb4_unicode_ci
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci
MySQL said: Documentation
#1046 - No database selected
What can I do to resolve this?
You need to USE a database. You could edit your file and add the line at the top, something like:
USE databasename;
Some tools will let you set a default database when restoring from backup. If you haven't selected one that could be a problem.
If you haven't created a database you'll need to do that first.
You need to select which database you are importing to in your SQL. Your first statement should be:
USE DATABASE `db_name`;
You have no database selected.
Find which databases exist
SHOW DATABASES:
and then select one for use
USE `database_name`
You say that you are importing into a new host, so I would assume that you do not already have a database created;
CREATE DATABASE `database_name`
Now you can USE that database you just created; and your queries should now work.

mysql error cant fix the error [duplicate]

This question already has answers here:
How can I fix MySQL error #1064?
(3 answers)
Closed 8 years ago.
I get an error from MySQL:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'TYPE=MyISAM AUTO_INCREMENT=7 AUTO_INCREMENT=7' at line 6
My SQL is:
CREATE TABLE IF NOT EXISTS `default_setup_academic` (
`academic_id` bigint(20) NOT NULL auto_increment,
`academic_name` text NOT NULL,
`academic_order` bigint(20) NOT NULL,
PRIMARY KEY (`academic_id`)
) TYPE=MyISAM AUTO_INCREMENT=7 AUTO_INCREMENT=7 ;
Why does that have an error?
TYPE is no longer in use.
Go with ENGINE
ENGINE=MyISAM
2 issues You have AUTO_INCREMENT=7 2 times and change the type to
ENGINE
CREATE TABLE IF NOT EXISTS
default_setup_academic
(
academic_id bigint(20) NOT NULL auto_increment,
academic_name text NOT NULL,
academic_order bigint(20) NOT NULL,
PRIMARY KEY (academic_id)
) ENGINE=MyISAM AUTO_INCREMENT=7 ;