how to fix this error when i import database into phpmyadmin cpanel:
SQL query:
--
-- Database: `news_letter`
--
-- --------------------------------------------------------
--
-- Table structure for table `banner_tbl`
--
CREATE TABLE IF NOT EXISTS `banner_tbl` (
`ban_id` INT( 11 ) NOT NULL ,
`banner_img` VARCHAR( 255 ) NOT NULL ,
`date` VARCHAR( 255 ) NOT NULL
) ENGINE = INNODB AUTO_INCREMENT =158 DEFAULT CHARSET = latin1;
MySQL said: Documentation
#1046 - No database selected
add the following lines on top of your .sql file
CREATE DATABASE IF NOT EXISTS `news_letter`;
USE `news_letter`;
Related
I exported the database, disabling foreign key checks (as advised by the webhost) and then imported it from the cPanel phpMyadmin.
It threw up the error below
Error
SQL query:
-- --------------------------------------------------------
--
-- Table structure for table `club_listing`
--
CREATE TABLE IF NOT EXISTS `club_listing` (
`id` INT( 11 ) NOT NULL ,
`name` VARCHAR( 50 ) NOT NULL ,
`venue` VARCHAR( 100 ) NOT NULL ,
`time` TIME( 4 ) NOT NULL ,
`description1` VARCHAR( 15 ) NOT NULL ,
`description2` VARCHAR( 15 ) NOT NULL ,
`description3` VARCHAR( 15 ) NOT NULL ,
`memberid` INT( 11 ) NOT NULL COMMENT 'foreignkey for members id for management',
`photoid` INT( 11 ) NOT NULL COMMENT 'link to photo table',
`imagefile` VARCHAR( 200 ) NOT NULL
) ENGINE = INNODB DEFAULT CHARSET = latin1;
MySQL said: Documentation
#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 '(4) NOT NULL,
description1 varchar(15) NOT NULL,
description2 varchar(15' at line 11
I zeroed the error to be the time datatype. However, I checked the mysql documentation and couldn't find anything that explains the error.
the webhost mysql is version 5.5 while xampp is 5.6
If you create it without the length it will compile, I would suggest that if you can get away with it, then just truncate the time to the correct precision in your sql calls. I was having the same error in phpmyadmin perhaps try it in command line.
I try to import a MySQL database on the localhost through phpmyadmin and i receive this error. what it means? and how can i solve it? any ideas?
SQL query:
--
-- Database: `casasdl_mag`
--
--
-- Database: `casasdl`
--
-- --------------------------------------------------------
--
-- Table structure for table `admin_assert`
--
CREATE TABLE IF NOT EXISTS `admin_assert` (
`assert_id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Assert ID',
`assert_type` VARCHAR( 20 ) DEFAULT NULL COMMENT 'Assert Type',
`assert_data` TEXT COMMENT 'Assert Data',
PRIMARY KEY ( `assert_id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 COMMENT = 'Admin Assert Table' AUTO_INCREMENT =1;
MySQL said: Documentation
#1046 - No database selected
When you create a table you need to select a database for that table to insert into
USE databaseName;
run this before your script
USE casasdl;
CREATE TABLE IF NOT EXISTS `admin_assert` (
`assert_id` INT( 10 ) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'Assert ID',
`assert_type` VARCHAR( 20 ) DEFAULT NULL COMMENT 'Assert Type',
`assert_data` TEXT COMMENT 'Assert Data',
PRIMARY KEY ( `assert_id` )
) ENGINE = INNODB DEFAULT CHARSET = utf8 COMMENT = 'Admin Assert Table' AUTO_INCREMENT =1;
Like you can read in error, you have to select your database.
Add USE yourDatabase; at the beginning of the code.
mysql or each db backend should import your tables into a Database , so it needs you introduce a db name , indeed you should tell to mysql :
use mydbname;
you can create it from :
mysqladmin -uroot -p create mydbname
mysql -uroot -p mydbname < mysqlfile.sql
if you are using external php, then do not use use database syntax or mysql-select_db("database"); syntax. Instead use mysqli_connect which accept database name.
The USE db_name statement tells MySQL to use the db_name database as the default (current) database for subsequent statements. The database remains the default until the end of the session or another USE statement is issued.
Refer: http://dev.mysql.com/doc/refman/5.6/en/use.html
Another option is within phpmyadmin Select DB from the left sidebar and inside it import will work.
I'm trying to import the database in MySQL but it kept on showing this error saying that 'no database selected'. Is there something wrong with my xampp? I've installed xampp v3.0.12.. Does anyone know how to solve this problem? I don't know what to do. :( I need to import this badly.This is the reason why I can't log in to wordpress. dAny help would be very much appreciated! Thanks!
Error
SQL query:
--
-- Database: eucincor_psuccessdb.sql
-- --------------------------------------------------------
-- Table structure for table wp_additional_attendees
CREATE TABLE IF NOT EXISTS `wp_additional_attendees` (
`id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT ,
`attendee_id` INT( 11 ) NOT NULL DEFAULT '0',
`x_attedee_name` VARCHAR( 45 ) DEFAULT NULL ,
`x_attendee_email` VARCHAR( 45 ) DEFAULT NULL ,
PRIMARY KEY ( `id` )
) ENGINE = MYISAM DEFAULT CHARSET = latin1 AUTO_INCREMENT =1;
MySQL said:
1046 - No database selected
you might would have forgotten to use database.
the dump file does not contain the
create database eucincor_psuccessdb
use eucincor_psuccessdb
either add manually this in the eucincor_psuccessdb.sql file or just type these commands before importing your database.
hope it worked!
When i try to import my DB i get this error. I don't know what I should do, please help.
--
-- Database: oddjobexchange
--
-- ---------------------------------------------------- --
--
TABLE structure FOR TABLE admin --
CREATE TABLE IF NOT EXISTS admin (
Email varchar( 30 ) NOT NULL ,
Password varchar( 35 ) NOT NULL ,
PRIMARY KEY ( Email )
) ENGINE = InnoDB DEFAULT CHARSET = latin1;
MySQL said: Documentation
#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 'Table structure for table admin
CREATE TABLE IF NOT EXISTS admin (
`Em' at line 10
help!
There needs to be a space after the first two dashes. Otherwise it is not a valid comment:
------------------------------------------------------ --
should be:
-- ---------------------------------------------------- --
Just need to add the follwing to top of file.
CREATE DATABASE databasename;
USE databasename;
I am trying to import the SQL database from my Drupal production site into a sandbox testing site on my local machine. I currently use XAMPP on my machine here at work.
I have downloaded my db aipiadxxm_if9DHdr.sql and then I go to the phpMyAdmin on http://localhost/phpmyadmin/index.php then to -> Import.
After I import the db I get this Error:
SQL query:
--
-- Database: `aipiadxxm_if9DHdr.sql`
--
-- --------------------------------------------------------
--
-- Table structure for table `if9d_access`
--
CREATE TABLE IF NOT EXISTS `if9d_access` (
`aid` int( 11 ) NOT NULL AUTO_INCREMENT ,
`mask` varchar( 255 ) NOT NULL default '',
`type` varchar( 255 ) NOT NULL default '',
`status` tinyint( 4 ) NOT NULL default '0',
PRIMARY KEY ( `aid` )
) ENGINE = MYISAM DEFAULT CHARSET = utf8 AUTO_INCREMENT =1;
MySQL said: Documentation
#1046 - No database selected
What is causing this error message: #1046 - No database selected ?
You need to create and/or select the database on your sandbox machine before importing the SQL for the table structure and data.
In phpMyAdmin, this means choosing a database from the sidebar and then using its import tab. If the database you want to fill doesn't exist, you have to create it first using the Create new database form.
After import, you should confirm that the export-import process hasn't affected the anonymous user record (uid 0).