Export from localhost to remote on the same LAN - mysql

I want to export one of my database to my Raspberry. I tried through PHPMyadmin, but on import I got this errormessage:
SQL query:
--
-- Database: `leltar`
--
-- --------------------------------------------------------
--
-- Table structure for table `eventlog`
--
CREATE TABLE `eventlog` (
`ID` int(50) NOT NULL,
`event` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`productbc` varchar(50) COLLATE utf8_hungarian_ci DEFAULT NULL,
`uname` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`datetime` datetime(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;
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 '(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci' at line 16
What's the matter?

Your datetime field has fractional seconds specified: datetime(1).
This feature is probably not supported by the target mysql version (< v5.7), hence the error message.
You either need to upgrade your target mysql version to support fractional seconds or you need to remove the fractional seconds from the export file, both from the data definition and the data itself.

CREATE TABLE `eventlog` (
`ID` int(50) NOT NULL,
`event` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`productbc` varchar(50) COLLATE utf8_hungarian_ci DEFAULT NULL,
`uname` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`datetime` DATETIME NOT NULL
) ;

Remove the "(1)" after the word "datetime" because it needs no length (sorry, it's not "length" it is a fractional seconds specification). The following should work:
CREATE TABLE `eventlog` (
`ID` int(50) NOT NULL,
`event` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`productbc` varchar(50) COLLATE utf8_hungarian_ci DEFAULT NULL,
`uname` varchar(50) COLLATE utf8_hungarian_ci NOT NULL,
`datetime` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_hungarian_ci;

Related

Why is sql not letting me create this table?

I'm trying to migrate a db
from: MySQL Distrib 5.5.60-MariaDB, for Linux (x86_64)
to: MySQL 5.5.4, UNIX
I tried importing the db as a zip package and it started throwing errors so now I'm trying to re-create each table one at a time on phpMyAdmin.
The query below is throwing a #1064 Syntax error, and I'm having trouble figuring out the issue.
MySQL Said:
#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 '(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`st' at line 6
I'm looking at line 6, trying to find any reserved words, missing data, typos, and or obsolete commands but no luck.
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
I could use some help.
Thanks in advance.
CURRENT_TIMESTAMP is not good
Try this:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp(2) NOT NULL DEFAULT CURRENT_TIMESTAMP(2) ON UPDATE CURRENT_TIMESTAMP(2),
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
This works in SQL Fiddle:
CREATE TABLE `tblmoto_auth_policies` (
`policy_id` int(11) NOT NULL AUTO_INCREMENT,
`policy_name` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
`policy_desc` text COLLATE utf8_unicode_ci NOT NULL,
`policy_url` text COLLATE utf8_unicode_ci NOT NULL,
`date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`status` smallint(2) NOT NULL DEFAULT '1',
PRIMARY KEY (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
i.e., remove the precision (the (2)) from the definition of the date_added column.
TIMESTAMP(2) is valid syntax, but not in combination with the DEFAULT CURRENT_TIMESTAMP nor ON UPDATE CURRENT_TIMESTAMP auto-initializers.

How to fix syntax error mysqli 1064 error

ım working localhost, after my work end. I want a upload my db server phpmyadmin. But still syntax error how can ı fix this?
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 '(6) NULL DEFAULT NULL,
PRIMARY KEY (id) USING BTREE
) ENGINE = InnoDB AUTO' at line 7 )
DROP TABLE IF EXISTS `veriler`;
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`gpa` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`durumu` int(10) NULL DEFAULT NULL,
`miktari` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
`tarih` datetime(6) NULL DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 1 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Compact;
Support for fractional seconds in DATETIME values wasn't added until version MySQL 5.6. If you can't upgrade your server, you will need to remove the trailing (6) from the definition of column tarih i.e.
`tarih` datetime NULL DEFAULT NULL,
Note that you will lose precision in those values relative to your MariaDB server. If you need to store microseconds in your data values, you will need to upgrade the MySQL server to version 5.6 or later.
Try this simplified version:
CREATE TABLE `veriler` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`kullanici` varchar(60) DEFAULT NULL,
`gpa` varchar(255) DEFAULT NULL,
`durumu` int(10) DEFAULT NULL,
`miktari` varchar(20) DEFAULT NULL,
`tarih` datetime(6) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;

Table already exist sql

When trying to import database
Error
SQL query:
CREATE TABLE `wp_ihrss_plugin` (
`Ihrss_id` int(11) NOT NULL,
`Ihrss_path` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Ihrss_link` text CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,
`Ihrss_target` varchar(50) NOT NULL,
`Ihrss_title` varchar(500) NOT NULL,
`Ihrss_order` int(11) NOT NULL,
`Ihrss_status` varchar(10) NOT NULL,
`Ihrss_type` varchar(100) NOT NULL,
`Ihrss_extra1` varchar(100) NOT NULL,
`Ihrss_extra2` varchar(100) NOT NULL,
`Ihrss_date` datetime NOT NULL DEFAULT '0000-00-00 00:00:00'
) ENGINE=MyISAM DEFAULT CHARSET=utf8
MySQL said: Documentation
#1050 - Table 'wp_ihrss_plugin' already exists
and 5 more tables ; when try to drop one it show that there is another one
One possible approacj to deal with this would be to drop and recreate the object. For instance:
DROP TABLE IF EXISTS `foo`;
CREATE TABLE `foo` ( ... );
There are some duplicate tables present in your database dump.
Check the sql file from which you are trying to import

What could be wrong here

DROP TABLE IF EXISTS 'ci_sessions';
CREATE TABLE 'ci_sessions' (
'session_id' varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '0',
'ip_address' varchar(16) COLLATE utf8_bin NOT NULL DEFAULT '0',
'user_agent' varchar(120) COLLATE utf8_bin DEFAULT NULL,
'last_activity' int(10) unsigned NOT NULL DEFAULT '0',
'user_data' text COLLATE utf8_bin NOT NULL, PRIMARY KEY ('session_id'),
KEY 'last_activity_idx' ('last_activity') )
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
I've tried to run this code on phpMyAdmin and it says
#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 ''ci_sessions'' at line 1
It's the same error in all your table and column names. You use ' while you should use backticks:
`
So this should work:
DROP TABLE IF EXISTS `ci_sessions`;
CREATE TABLE `ci_sessions` (
`session_id` varchar(40) COLLATE utf8_bin NOT NULL DEFAULT '0',
`ip_address` varchar(16) COLLATE utf8_bin NOT NULL DEFAULT '0',
`user_agent` varchar(120) COLLATE utf8_bin DEFAULT NULL,
`last_activity` int(10) unsigned NOT NULL DEFAULT '0',
`user_data` text COLLATE utf8_bin NOT NULL, PRIMARY KEY (`session_id`),
KEY `last_activity_idx` (`last_activity`) )
ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
As a sidenote - you use NOT NULL and then set the default value to the string 0. quite often. That indicates bad practice, or at least more work for later queries. A column named last_activity for example indicates that null values should be allowed...
Second sidenote - last_activity would typically be a DATETIME column, not an int(10)

Mysql i get Error when i try to edit after insert data

this is my one of database table structure and after insert some fields as row into that i can't update columns and i get error:
CREATE TABLE `channels` (
`id` int(11) NOT NULL,
`channelName` varchar(30) COLLATE utf8_persian_ci NOT NULL,
`channelLink` varchar(50) COLLATE utf8_persian_ci NOT NULL,
`channelDescription` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelImageFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelAvatarFileName` varchar(100) COLLATE utf8_persian_ci NOT NULL,
`channelState` tinyint(1) NOT NULL,
`channelType` enum('channels','userCreatedChannels') COLLATE utf8_persian_ci NOT NULL,
`channelOwnerUserId` int(11) NOT NULL,
`fileServerUrlId` int(11) NOT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_persian_ci;
--
-- Indexes for dumped tables
--
--
-- Indexes for table `channels`
--
ALTER TABLE `channels`
ADD PRIMARY KEY (`id`);
Error and notice:
This table does not contain a unique column. Features related to the grid edit, checkbox, Edit, Copy and Delete links may not work after saving.
Error
UPDATE `channels` SET `channelState` = '1' WHERE LIMIT 1
MySQL said: Documentation
#1064 - 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 'LIMIT 1' at line 1
id of this table is unique and A_I, how can i resolve this problem?