Can't import MySQL database in phpMyAdmin - mysql

I am importing database in phpMyAdmin but having errors. I tried too much but showing same errors, here is SQL database:
CREATE TABLE `business` (
`b_id` bigint(20) NOT NULL AUTO_INCREMENT,
`b_title` text,
`b_lastmodified` datetime DEFAULT NULL,
`b_detail` text,
`b_banner_image` varchar(250) DEFAULT NULL,
`b_cat_id` int(10) DEFAULT '100',
`b_subcat_id` int(10) DEFAULT NULL,
`b_tags` text,
`b_user_id` bigint(20) DEFAULT NULL,
`b_isactive` tinyint(1) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` datetime DEFAULT NULL,
`b_views` bigint(20) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY (`b_id`)
) ENGINE=MyISAM AUTO_INCREMENT=764 DEFAULT CHARSET=utf8;
INSERT INTO `business` (`b_id`, `b_title`, `b_lastmodified`, `b_detail`, `b_banner_image`, `b_cat_id`, `b_subcat_id`, `b_tags`, `b_user_id`, `b_isactive`, `b_created_on`, `b_views`) VALUES ('1', 'Couple Names Silver Pendant', '2014-01-15 02:25:02', '', 'itm_couple-names-silver-pendant2013-03-25_22-07-16_1.jpg', '35', '0', 'love pendant,name pictures,silver name pendant,couple name pendant,locket of love,chain of name,fb display photos', '1', '1', '2013-03-25 22:06:53', '7263');
And showing these errors:
Error
SQL query:
CREATE TABLE `business` (
`b_id` BIGINT( 20 ) NOT NULL AUTO_INCREMENT ,
`b_title` TEXT,
`b_lastmodified` DATETIME DEFAULT NULL ,
`b_detail` TEXT,
`b_banner_image` VARCHAR( 250 ) DEFAULT NULL ,
`b_cat_id` INT( 10 ) DEFAULT '100',
`b_subcat_id` INT( 10 ) DEFAULT NULL ,
`b_tags` TEXT,
`b_user_id` BIGINT( 20 ) DEFAULT NULL ,
`b_isactive` TINYINT( 1 ) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` DATETIME DEFAULT NULL ,
`b_views` BIGINT( 20 ) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY ( `b_id` )
) ENGINE = MYISAM AUTO_INCREMENT =764 DEFAULT CHARSET = utf8;
MySQL said: Documentation
#1046 - No database selected

In phpMyAdmin make a new database or select an existing database. Then import the SQL file.
or
Include below lines into your first line of the sql script.
create database database_name;
use database_name;

You have not selected a database in which you want to create the table and start the import. This is why you get that error.
You should click on the database you are importing in, before you go to the query window and execute the query.
Another option is to select the database, like this:
USE `database_name`;
CREATE TABLE `business` (
`b_id` bigint(20) NOT NULL AUTO_INCREMENT,
`b_title` text,
`b_lastmodified` datetime DEFAULT NULL,
`b_detail` text,
`b_banner_image` varchar(250) DEFAULT NULL,
`b_cat_id` int(10) DEFAULT '100',
`b_subcat_id` int(10) DEFAULT NULL,
`b_tags` text,
`b_user_id` bigint(20) DEFAULT NULL,
`b_isactive` tinyint(1) DEFAULT '0' COMMENT 'admin will approve it',
`b_created_on` datetime DEFAULT NULL,
`b_views` bigint(20) DEFAULT '0' COMMENT 'number of times this is viewed',
PRIMARY KEY (`b_id`)
) ENGINE=MyISAM AUTO_INCREMENT=764 DEFAULT CHARSET=utf8;
INSERT INTO `business` (`b_id`, `b_title`, `b_lastmodified`, `b_detail`, `b_banner_image`, `b_cat_id`, `b_subcat_id`, `b_tags`, `b_user_id`, `b_isactive`, `b_created_on`, `b_views`) VALUES ('1', 'Couple Names Silver Pendant', '2014-01-15 02:25:02', '', 'itm_couple-names-silver-pendant2013-03-25_22-07-16_1.jpg', '35', '0', 'love pendant,name pictures,silver name pendant,couple name pendant,locket of love,chain of name,fb display photos', '1', '1', '2013-03-25 22:06:53', '7263');

Related

MariaDB - CONNECT ENGINE - ORDER BY error

I'm trying to get Asterisk CDR records from MySQL table (5.5.45) by CONNECT engine on other server running MariaDB (10.0.29).
I can create the connection between table easily:
CREATE TABLE `calls` engine=CONNECT table_type=MYSQL
CONNECTION='mysql://user#IP/asteriskcdrdb/calls';
When I run simple SELECT * FROM calls, everything works good, when I add some WHERE conditions, still everything okay.
But the problem start when I add ORDER BY column parameter, then I got this error from MariaDB:
#1032 - Can't find record in 'calls'
I checked MySQL log, MariaDB log - there are no errors at all.
Did I miss something?
Thank you!
Update: The whole query is simple:
SELECT * FROM `calls` ORDER BY `calldate`
The table structure:
CREATE TABLE `calls` (
`calldate` datetime NOT NULL default '0000-00-00 00:00:00',
`clid` varchar(80) NOT NULL default '',
`src` varchar(80) NOT NULL default '',
`dst` varchar(80) NOT NULL default '',
`dcontext` varchar(80) NOT NULL default '',
`channel` varchar(80) NOT NULL default '',
`dstchannel` varchar(80) NOT NULL default '',
`lastapp` varchar(80) NOT NULL default '',
`lastdata` varchar(80) NOT NULL default '',
`duration` int(11) NOT NULL default '0',
`billsec` int(11) NOT NULL default '0',
`disposition` varchar(45) NOT NULL default '',
`amaflags` int(11) NOT NULL default '0',
`accountcode` varchar(20) NOT NULL default '',
`uniqueid` varchar(32) NOT NULL default '',
`userfield` varchar(255) NOT NULL default '',
`recordingfile` varchar(255) NOT NULL default '',
`cnum` varchar(40) NOT NULL default '',
`cnam` varchar(40) NOT NULL default '',
`outbound_cnum` varchar(40) NOT NULL default '',
`outbound_cnam` varchar(40) NOT NULL default '',
`dst_cnam` varchar(40) NOT NULL default '',
`call_charge` float NOT NULL default '0',
`from_did` varchar(30) NOT NULL,
`did` varchar(50) NOT NULL default '',
`user_id` int(8) unsigned default NULL,
`client_id` int(8) unsigned default NULL,
KEY `IDX_UNIQUEID` (`uniqueid`),
KEY `src` (`src`),
KEY `dst` (`dst`),
KEY `calldate` (`calldate`),
KEY `uniqueid` (`uniqueid`),
KEY `userfield` (`userfield`),
KEY `from_did` (`from_did`),
KEY `user_id` (`user_id`),
KEY `client_id` (`client_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Update #2: Update the table names, to don't confuse, but it's not the issue. The CONNECTION table is created okay.
Query works:
SELECT * FROM `calls`
Query works:
SELECT * FROM `calls` WHERE `user_id`=X
Query return error:
SELECT * FROM `calls` ORDER BY `calldate`
Update #3: The MySQL was updated to veriosn 5.5.45, the type was changed to InnoDB and the charset was converted to UTF8. But no success.
PROBLEM SOLVED
Well, it's MariaDB bug, when I changed to FederatedX engine (which is basically little bit limited version of CONNECT), everything works as expected.
In your query you do
SELECT * FROM calls
but in your table structure you have
CREATE TABLE cdr
and both have calldate column. Check if you querying the right table.

error upload .sql file of wordpress site

this is the error
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 'AS ical subscribe access key,
created_on datetime DEFAULT NULL,
`updated' at line 20
Erreur
requĂȘte SQL:
-- --------------------------------------------------------
--
-- Structure de la table `pec_calendars`
--
CREATE TABLE `pec_calendars` (
`id` INT( 11 ) UNSIGNED NOT NULL ,
`type` ENUM( 'user', 'group', 'url' ) DEFAULT 'user',
`user_id` INT( 11 ) UNSIGNED DEFAULT NULL ,
`name` VARCHAR( 100 ) DEFAULT NULL ,
`description` TEXT,
`color` VARCHAR( 7 ) DEFAULT NULL ,
`admin_id` INT( 11 ) DEFAULT NULL ,
`status` ENUM( 'on', 'off' ) DEFAULT 'on',
`show_in_list` ENUM( '0', '1' ) DEFAULT NULL ,
`public` TINYINT( 3 ) UNSIGNED DEFAULT '0',
`reminder_message_email` TEXT,
`reminder_message_popup` TEXT,
`access_key` VARCHAR( 32 ) DEFAULT NULL COMMENT AS `ical subscribe access key` ,
`created_on` DATETIME DEFAULT NULL ,
`updated_on` DATETIME DEFAULT NULL
) ENGINE = INNODB DEFAULT CHARSET = utf8;
Guess your query should be:
CREATE TABLE pec_calendars
(
id INT(11) UNSIGNED NOT NULL,
type ENUM('user', 'group', 'url') DEFAULT 'user',
user_id INT(11) UNSIGNED DEFAULT NULL,
name VARCHAR(100) DEFAULT NULL,
description TEXT,
color VARCHAR(7) DEFAULT NULL,
admin_id INT(11) DEFAULT NULL,
status ENUM('on', 'off') DEFAULT 'on',
show_in_list ENUM('0', '1') DEFAULT NULL,
public TINYINT(3) UNSIGNED DEFAULT '0',
reminder_message_email TEXT,
reminder_message_popup TEXT,
access_key VARCHAR(32) DEFAULT NULL,
created_on DATETIME DEFAULT NULL,
updated_on DATETIME DEFAULT NULL
)
engine = innodb
DEFAULT charset = utf8;

Create table in magento module

I am new in magento. How can I create table in db ? I tried some code, but table didn't create. But in core_resource table I have setup my table. The version of my php file is match with version of my config file. Help me please, I am looking answer for that question two days , but nowhere can find anything.
There are many ways to create a table.
You can create table by direct phpmyadmin
write own sql and run that by php file
Both ways are applicable on magento too.
but if you are trying to create your own table by your own custom module then you have to play with xml and magento models.
I am providing you an example of module.
XML
<models>
<magenotification>
<class>Magestore_Magenotification_Model</class>
<resourceModel>magenotification_mysql4</resourceModel>
</magenotification>
<magenotification_mysql4>
<class>Magestore_Magenotification_Model_Mysql4</class>
<entities>
<magenotification>
<table>magenotification</table>
</magenotification>
<feedback>
<table>magenotification_extension_feedback</table>
</feedback>
<feedbackmessage>
<table>magenotification_extension_feedbackmessage</table>
</feedbackmessage>
<logger>
<table>magenotification_log</table>
</logger>
<license>
<table>magenotification_license</table>
</license>
</entities>
</magenotification_mysql4>
</models>
SQL
<?php
$installer = $this;
$installer->startSetup();
$installer->run("
DROP TABLE IF EXISTS {$this->getTable('magenotification_extension_feedbackmessage')};
DROP TABLE IF EXISTS {$this->getTable('magenotification_extension_feedback')};
DROP TABLE IF EXISTS {$this->getTable('magenotification_log')};
DROP TABLE IF EXISTS {$this->getTable('magenotification')};
CREATE TABLE {$this->getTable('magenotification')} (
`magenotification_id` int(11) unsigned NOT NULL auto_increment,
`notification_id` int(10) unsigned NOT NULL,
`url` varchar(255) NOT NULL default '',
`added_date` datetime NOT NULL,
UNIQUE (`notification_id`, `url`),
PRIMARY KEY (`magenotification_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_log')} (
`log_id` int(11) unsigned NOT NULL auto_increment,
`extension_code` varchar(100) NOT NULL default '',
`license_type` varchar(50) NOT NULL default '',
`license_key` text NOT NULL default '',
`check_date` date NOT NULL,
`sum_code` varchar(255),
`response_code` smallint(5),
`expired_time` varchar(255),
`is_valid` tinyint(1),
PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_extension_feedback')} (
`feedback_id` int(11) unsigned NOT NULL auto_increment,
`code` varchar(255) NOT NULL default '',
`extension` varchar(255) NOT NULL default '',
`extension_version` varchar(50) NOT NULL default '',
`coupon_code` varchar(255) NOT NULL default '',
`coupon_value` varchar(50) NOT NULL default '',
`expired_counpon` datetime NOT NULL,
`content` text NOT NULL default '',
`file` text NOT NULL default '',
`comment` text NOT NULL default '',
`latest_message` text NOT NULL default '',
`latest_response` text NOT NULL default '',
`latest_response_time` datetime,
`status` tinyint(1) NOT NULL DEFAULT '3',
`is_sent` tinyint(1) NOT NULL DEFAULT '2',
`created` datetime NOT NULL,
`updated` datetime NOT NULL,
PRIMARY KEY (`feedback_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE {$this->getTable('magenotification_extension_feedbackmessage')} (
`feedbackmessage_id` int(11) unsigned NOT NULL auto_increment,
`feedback_id` int(11) unsigned NOT NULL,
`feedback_code` varchar(255) NOT NULL default '',
`user` varchar(255) NOT NULL default '',
`is_customer` tinyint(1) default '2',
`message` text NOT NULL default '',
`file` text NOT NULL default '',
`posted_time` datetime NULL,
`is_sent` tinyint(1) default '2',
PRIMARY KEY (`feedbackmessage_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
");
$installer->endSetup();
You have to learn how to create custom module in magento for more information.
custom module with database

What's wrong with this MySQL INSERT query

I'm trying to insert the data below into an existing table, and it gives me sql error 1064, you have an error in your sql syntax at line 3.
INSERT INTO `static_contract` (`ID`, `contractID`, `name`, `mobbaseID`, `classID`, `dialogID`, `menuoptions`, `iconID`, `notes`, `vendorID`, `pTable`, `sTable`, `itemModTable`, `allowedBuildingTypeID`)
VALUES
(2026, 2026, 'Premium Vendor', 15312, 1906, 600, '1 2 15 18', 68, 'vendor', 0, '0', '0', '', 0),
Here's the table schema:
CREATE TABLE `static_contract` (
`ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`contractID` int(10) unsigned NOT NULL,
`name` varchar(100) NOT NULL DEFAULT '',
`mobbaseID` int(10) unsigned NOT NULL,
`classID` int(10) unsigned NOT NULL,
`dialogID` int(10) unsigned NOT NULL,
`menuoptions` varchar(20) NOT NULL DEFAULT '',
`iconID` tinyint(3) unsigned NOT NULL DEFAULT '0',
`notes` varchar(50) NOT NULL DEFAULT '',
`vendorID` int(10) NOT NULL DEFAULT '0',
`pTable` varchar(50) NOT NULL DEFAULT '0',
`sTable` varchar(50) NOT NULL DEFAULT '0',
`itemModTable` varchar(50) NOT NULL DEFAULT '',
`allowedBuildingTypeID` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`),
KEY `fk_contracts_mobbase` (`mobbaseID`)
) ENGINE=InnoDB AUTO_INCREMENT=302900 DEFAULT CHARSET=latin1
The comma outside of your parenthesis at the end is the problem. Please select an answer to mark this question as complete.
First off, I believe it is complaining about the comma at the end of your statement on line 3.
Second, you are putting a value into an auto-increment column ID.
Third, why are you specifying every column to insert into if you're inserting something in every column? Just do:
INSERT INTO static_contract VALUES (...)

What causes duplicate PKs in MySQL?

I encountered this quite a few times so far, but still don't understand it (my MySQL internals skills are equal to none).
I know it's probably a PEBKAC but trying to replicate the behavior manually ends up with an error (autoincrement).
CREATE TABLE `foo_bar` (
`id` int(12) unsigned NOT NULL AUTO_INCREMENT,
`user_id` int(12) unsigned DEFAULT NULL,
`order_id` int(12) unsigned DEFAULT NULL,
`email_address` varchar(50) DEFAULT NULL,
`mobile_number` varchar(20) DEFAULT NULL,
`message` longtext NOT NULL,
`message_received` int(12) unsigned DEFAULT NULL,
`failed_to_send` tinyint(1) unsigned DEFAULT NULL,
`fraudulent_activity` tinyint(1) unsigned DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=ARCHIVE DEFAULT CHARSET=utf8;
When your program inserts a row in the database, it should provide NULL as the value for auto-incremented field:
CREATE TABLE `customers` (
`id` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`name` VARCHAR( 128 ) NOT NULL
) ENGINE = MYISAM ;
INSERT INTO `customers` ( `id` , `name` )
VALUES ( NULL , 'Customer 1' ), ( NULL , 'Customer 2' );
If you try to insert a specific value in id field, MySQL will give an error:
SQL query:
INSERT INTO `customers` ( `id` , `name` )
VALUES ( '1', 'Customer 3' );
MySQL said:
#1062 - Duplicate entry '1' for key 'PRIMARY'
Although the answer to "what caused this" didn't come up, REPAIR TABLE fixes the problem.
Answering this so I can close the question.