Wordpress MySQL wp_post export/ import - mysql

I'm trying to export an old wp_posts database into a new one, and I'm hitting a few brick walls.
I'm currently exporting in SQL compatibility mode: MYSQL40.
Here's the error:
--
-- Database: `grafiqe`
--
-- --------------------------------------------------------
--
-- Table structure for table `wp_actionscheduler_actions`
--
CREATE TABLE `wp_actionscheduler_actions` (
`action_id` bigint(20) UNSIGNED NOT NULL,
`hook` varchar(191) NOT NULL,
`status` varchar(20) NOT NULL,
`scheduled_date_gmt` datetime DEFAULT '0000-00-00 00:00:00',
`scheduled_date_local` datetime DEFAULT '0000-00-00 00:00:00',
`args` varchar(191) DEFAULT NULL,
`schedule` longtext,
`group_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`attempts` int(11) NOT NULL DEFAULT '0',
`last_attempt_gmt` datetime DEFAULT '0000-00-00 00:00:00',
`last_attempt_local` datetime DEFAULT '0000-00-00 00:00:00',
`claim_id` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`extended_args` varchar(8000) DEFAULT NULL
)
MySQL said: Documentation
#1050 - Table 'wp_actionscheduler_actions' already exists```

Your code snippet already tells you the error
#1050 - Table 'wp_actionscheduler_actions' already exists```
It's not possible to create a table with the name of a table that already exists in the database. Daft question, but are you importing it into the new empty database and not the same one you just exported it from?

Related

MySQL Insert Slow in AWS RDS

I'm trying to INSERT/UPDATE and realized it's taking about 15 seconds.
The table has only a few records (+/- 350 records) and is in an RDS instance db.t2.small
Table:
CREATE TABLE `ajustes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`tipo_id` int(10) unsigned DEFAULT '1',
`nome` varchar(255) NOT NULL DEFAULT '',
`valor` text NOT NULL,
`array` tinyint(1) unsigned NOT NULL DEFAULT '0',
`created` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
`modified` datetime NOT NULL DEFAULT '1000-01-01 00:00:00',
PRIMARY KEY (`id`),
KEY `tipo_id` (`tipo_id`),
KEY `nome` (`nome`)
) ENGINE=InnoDB AUTO_INCREMENT=351 DEFAULT CHARSET=latin1;
I do not even know where to begin with.
I tried to use REPAIR but see the error:
The storage engine for the table doesn't support repair
I disabled two parameters and it works:
sync-binlog = 0
innodb_flush_log_at_trx_commit = 0

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.

Mysql Append table to add columns

I like to append a table to add column but without using alert table command
e.g.
This is the table which is missing some columns.
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`passwd` varchar(40) NOT NULL,
`isActive` tinyint(1) NOT NULL default '1',
`lastVisit` datetime NOT NULL default '0000-00-00 00:00:00',
`modifyAt` datetime NOT NULL,
`createdAt` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
So if i run this query then it should automatically add missing columns into my tables
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`passwd` varchar(40) NOT NULL,
`name` varchar(100) NOT NULL,
`originalUser` tinyint(1) NOT NULL default '0',
`isActive` tinyint(1) NOT NULL default '1',
`lastVisit` datetime NOT NULL default '0000-00-00 00:00:00',
`modifyAt` datetime NOT NULL,
`createdAt` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
Can this be possible to do without using alert table command ?
I understand your question as you want to add some columns to your table. Please be informed that the term row is usually related to the actual data in your table, not the columns itself. If my assumption is wrong, please clarify your question.
You cannot use CREATE TABLE for altering a table. It is there to create table,
and if it cannot create it, it will in most cases throw an error like you described. Another command exists for that reason: ALTER TABLE.
You might do it something like this.
(1) Create your table with your CREATE TABLE syntax above:
CREATE TABLE IF NOT EXISTS `admin` (
`id` int(11) NOT NULL auto_increment,
`username` varchar(20) NOT NULL,
`passwd` varchar(40) NOT NULL,
`isActive` tinyint(1) NOT NULL default '1',
`lastVisit` datetime NOT NULL default '0000-00-00 00:00:00',
`modifyAt` datetime NOT NULL,
`createdAt` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
(2) Use ALTER TABLE like this to make the modifications I think you want to have in your second statement (two more columns):
ALTER TABLE
ADD COLUMN `name` varchar(100) NOT NULL AFTER `passwd`,
ADD COLUMN `originalUser` tinyint(1) NOT NULL default '0' AFTER `name`;
Not related to your question, but I'd avoid column names like name, because if you don't escape them properly it'll throw you other errors (see reserved words).

MYSQL script import error

I am getting an error when I try to import data through the command:
mysql -u root -p"root" cvdb < "cvdb.sql"
The error I am getting is:
ERROR 1064 (42000) at line 72: 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 '(14) NOT NULL,
Created datetime NOT NULL default ' 0000-00-00 00:00:00 ',
' at line 14
The code of my SQL file is:
DROP TABLE IF EXISTS `activity`;
CREATE TABLE `activity` (
`AllDay` enum('YES','NO') default 'NO',
`ActivityID` int(11) unsigned NOT NULL auto_increment,
`Type` int(11) NOT NULL default '0',
`Priority` int(11) NOT NULL default '0',
`Status` int(11) NOT NULL default '0',
`Title` varchar(255) default NULL,
`DueDate` datetime default NULL,
`CompletedDate` datetime default NULL,
`Details` text,
`Creator` int(11) NOT NULL default '0',
`Owner` int(11) default NULL,
`ModifiedBy` int(11) default NULL,
`Modified` timestamp(14) NOT NULL,
`Created` datetime NOT NULL default ' 0000-00-00 00:00:00 ',
`Start` datetime default NULL,
`End` datetime default NULL,
`AttachmentType` enum('NONE','FILE','LINK') NOT NULL default 'NONE',
`Location` varchar(25) default NULL,
`visibility` enum('PRIVATE','PUBLIC') NOT NULL default 'PRIVATE',
`Notes` varchar(255) default NULL,
PRIMARY KEY (`ActivityID`),
UNIQUE KEY `ActivityID` (`ActivityID`),
KEY `Type` (`Type`),
KEY `Priority` (`Priority`),
KEY `Status` (`Status`),
KEY `Creator` (`Creator`),
KEY `Owner` (`Owner`),
KEY `ModifiedBy` (`ModifiedBy`),
KEY `Location` (`Location`)
) ENGINE=InnoDB;
the error is here Modified timestamp(14) NOT NULL. you should remove (14) from timestamp.
your partial DDL,
`ModifiedBy` int(11) default NULL,
`Modified` timestamp NOT NULL,
`Created` datetime NOT NULL default '0000-00-00 00:00:00',
`Start` datetime default NULL,
From mysql doc
Incompatible change: In very old versions of MySQL (prior to 4.1), the
TIMESTAMP data type supported a display width, which was silenty
ignored beginning with MySQL 4.1. This is deprecated in MySQL 5.1, and
removed altogether in MySQL 5.5. These changes in behavior can lead to
two problem scenarios when trying to use TIMESTAMP(N) columns with a
MySQL 5.5 or later server:
...
You should try to handle potential issues of these types proactively
by updating with ALTER TABLE any TIMESTAMP(N) columns in your
databases so that they use TIMESTAMP instead, before performing any
upgrades.
So try to remove the (14)
in
Modified timestamp(14) NOT NULL
or as said in doc, try to make alter table statements on your timestamp columns before import.

importing mysql file into access DB

i need to import a mysql file into my access db. how do i do this?
here's a sample of the mysql file:
*
MySQL Data Transfer
Source Host: 10.0.0.5
Source Database: jnetdata
Target Host: 10.0.0.5
Target Database: jnetdata
Date: 5/26/2009 12:27:33 PM
*/
SET FOREIGN_KEY_CHECKS=0;
-- ----------------------------
-- Table structure for chavrusas
-- ----------------------------
CREATE TABLE `chavrusas` (
`id` int(11) NOT NULL auto_increment,
`date_created` datetime default NULL,
`luser_id` int(11) default NULL,
`ruser_id` int(11) default NULL,
`luser_type` varchar(50) default NULL,
`ruser_type` varchar(50) default NULL,
`SessionDay` varchar(250) default NULL,
`SessionTime` datetime default NULL,
`WeeklyReminder` tinyint(1) NOT NULL default '0',
`reminder_phone` tinyint(1) NOT NULL default '0',
`calling_card` varchar(50) default NULL,
`active` tinyint(1) NOT NULL default '0',
`notes` mediumtext,
`ended` tinyint(1) NOT NULL default '0',
`end_date` datetime default NULL,
`initiated_by_student` tinyint(1) NOT NULL default '0',
`initiated_by_volunteer` tinyint(1) NOT NULL default '0',
directly from that file won't be easy. i suggest instead installing mysql and myodbc. once you have the database loaded in mysql, you can connect to the database in access using an ODBC linked table. from their you can either access the data directly and just use access as a front-end to the database, or you can create tables and copy the rows in to access.