SQL Syntax errors in VS Code in local vs remote host - mysql

I'm trying to containerize an app so I'm trying to write an init file for a MariaDB database for an existing database that exists on a remote server. I'm using VS Code to connect to the remote server and the .sql file with the contents of the dump has no errors, but when I try and copy it to a different workspace on my local computer, I get many syntax errors.
Examples of the syntax errors:
DROP TABLE IF EXISTS `accounts`;
CREATE TABLE `accounts` (
`table_number` int(11) NOT NULL AUTO_INCREMENT,
`account_id` varchar(12) NOT NULL,
`account_name` varchar(5) NOT NULL,
PRIMARY KEY (`table_number`)
) ENGINE=InnoDB AUTO_INCREMENT=261 DEFAULT CHARSET=latin1;
Incorrect syntax near '`'. Expecting '(', or SELECT.
Incorrect syntax near '11'. Expecting '(', or SELECT.
The error about the ` character is present before "accounts" and before both instances of "table_number" but not before "account_id" and "account_name". Every number in the CREATE has the incorrect syntax warning. I've tried retyping rather than copy and pasting to see if there's hidden characters responsible for these issues, but no luck.
Is this an OS issue? The remote server is a CentOS machine and my local is macOS Catalina. A setting in VS Code I need to specify or change?

Related

Error when importing a SQL file using phpMyAdmin

I am not proficient in MySQL and phpMyAdmin and got this error when trying to import my SQL file to a new installation of WAMP. I was developing a joomla website on my local pc and after completion, decided to launch it online with Rochen web hosting. When importing this into my Cpanel, it gave me the error below.
Error
Static analysis:
errors were found during analysis.
A closing bracket was expected. (near ")" at position 276)
SQL query:
Database: kwadi.
Table structure for table iq2rf_assets:
CREATE TABLE `iq2rf_assets`
(
`id` int(10) UNSIGNED NOT NULL COMMENT 'Primary Key',
`parent_id` int(11) NOT NULL DEFAULT '0'COMMENT
)
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 ')' at line 14
I tried to resolve with their support but their advice was for me to upgrade my WAMP Server on my local pc to the one that has MariaDB in it and try extract. Now after installing the new WAMP server i am faced with the same issue when trying to import my back up db using phpmyadmin.
It is giving me the same error. I do not know what to do.
Need assistance.
CREATE TABLE iq2rf_assets ( id int(10) UNSIGNED NOT NULL COMMENT 'Primary Key', parent_id int(11) NOT NULL DEFAULT '0')
You do not have a comment on the second field (parent_id), yet you are using the keyword "COMMENT" only to be closing the query after that. Remove it and you're good to go
The assets table has more fields than the 2 fields shown in your post.
This is the reason for the failed import, check your export.

How i can downgrade my SQL file from 5.6 to 5.5

i need some help regarding how to downgrade my sql database file from 5.6 to 5.5, because i did changed my hosting.my old hosting server was 5.6 and new server version was 5.5, i am getting error while i am importing the data base file..
support says:"you are running MySQL Server version: 5.5.51-38.2. Which is why you are having issues importing the database. You would need MySQL 5.6 for that database." ..any one can please help me in it ??
i have uploaded my sql file here please check: http://www88.zippyshare.com/v/bbzjmvCJ/file.html
and please fix it if you can. i am very thankful to you...
error i am getting while uploading is here :
CREATE TABLE `wpqc_o3n8w99opanda_leads_fields` (
`wpqc_o3n8w99opanda_leads_fields`.`lead_id` int(10) unsigned,
`wpqc_o3n8w99opanda_leads_fields`.`field_name` varchar(255),
`wpqc_o3n8w99opanda_leads_fields`.`field_value` text,
`wpqc_o3n8w99opanda_leads_fields`.`field_custom` bit(1) DEFAULT 'b\'0\'',
UNIQUE `UK_wp_opanda_leads_fields` (`lead_id`,`field_name`),
KEY `IDX_wp_opanda_leads_fields_field_name` (`field_name`)
)/*! engine=MyISAM */;
MySQL said:
#1067 - Invalid default value for 'field_custom'
The default value for a bit field should be DEFAULT b'0' this is not a difference between v5.5 and 5.6, it is probably an issue with the export, which considered b'0' as a string and encapsulated it into extra single quotes and escaped the original single quotes.

Cannot duplicate mysql database using phpmyadmin export/import on same server

I am trying to duplicate one of my databases on a remote bluehost server in order to setup a dev and stage environment for my drupal website. Dev is already setup/populated and working fine, so I am now simply trying to duplicate the dev database. Using phpmyadmin on windows (PHP 5.2.17, MySQL 5.5.42). I have done the following steps:
created site_stage database
exported/dumped all tables from site_dev db into compressed sql.gz file
imported all tables into site_stage db
Import fails with $1064 error:
INSERT INTO `cache_bootstrap` (`cid`, `data`, `expire`, `created`, `serialized`, `tags`, `checksum`) VALUES
('system_list', 0x613a323a7b733a353a227468656d65223b613a31333a7b733a363a2262617274696b223b433a33313a2244727570616c5c436f72655c457874656e73696f6e5c457874656e73696f6e223a323339343a7b613a31363a7b733a343a2274797065223b733a353a227468656d65223b733a383a22706174686e616d65223b733a33343a22636f72652f7468656d65732f62617274696b2f62617274696b2e696e666f2e796d6c223b733a383a2266696c656e616d65223b733a31323a2262617274696b2e7468656d65223b733a373a2273756270617468223b733a31333a227468656d65732f62617274696b223b733a363a226f726967696e223b733a343a22636f7265223b733a363a22737461747573223b693a313b733a343a22696e666f223b613a31393a7b733a343a226e616d65223b733a363a2242617274696b223b733a343a2274797065223b733a353a227468656d65223b733a31303a2262617365207468656d65223b733a363a22636c61737379223b733a31313a226465736372697074696f6e223b733a38363a224120666c657869626c652c207265636f6c6f7261626c65207468656d652077697468206d616e79[...]
#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 '?' at line 2
Thought maybe it didn't like the length of that value, so I just deleted that cache_bootstrap query from uncompressed version of dump file (shouldn't need this cache table anyways) and tried to import again, this time, it failed with the following error:
CREATE TABLE IF NOT EXISTS `key_value` (
`collection` varchar(128) CHARACTER SET ascii NOT NULL DEFAULT '' COMMENT 'A named collection of key and value pairs.'
`value` longblob NOT NULL COMMENT 'The value.',
PRIMARY KEY (`collection`,`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='Generic key-value storage table. See the state system for…';
#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 '`value` longblob NOT NULL COMMENT 'The value.',
PRIMARY KEY (`collection`,`nam' at line 9
I've read a lot of '1064 error on import' threads, but none of them help and most of them pertain to moving sql data between servers. Very strange that I would get syntax errors copying tables from one database to another on same server, with same mysql version, etc. Any ideas? Thanks in adv.

MySQL Errcode: 13 - Permission denied

I'm using MySQL 5.7.10 and Flyway to handle my database migrations. Everything works fine on Linux and Mac but on Windows 10 I am getting this error:
Error on rename of '.\mydb\#sql-1da0_a.frm' to '.\mydb\proc_error_table.frm' (Errcode: 13 - Permission denied)
This is part of the SQL in question causing the error:
DROP TABLE IF EXISTS `proc_error_table`;
DROP TABLE IF EXISTS `error_import`;
CREATE TABLE `proc_error_table` (
`procedure_name` varchar(30) NOT NULL,
`sql_state` varchar(20) NOT NULL,
`sql_message` varchar(100) NOT NULL,
`error_timestamp` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
create index idx_proc on proc_error_table(procedure_name);
#
# This is the line causing the error.
#
create index idx_file_id on proc_error_table(data_set_file_id);
I tried explicitly defining a tmpdir with sufficient privileges but that didn't work:
tmpdir = C:/temp
I tried to give explicit FULL ACCESS to the data FULL ACCESS to the MySQL Data directory but that didn't work:
C:\ProgramData\MySQL\MySQL Server 5.7\Data\mydb
I tried changing the user that MySQL runs as to my personal account and that didn't work.
Something, somewhere is preventing MySQL from gaining access to this directory and or file(s). The Windows Event Log, nor the MySQL show any indications as to what is preventing it.
What tool can I use to figure this out?
it could be a conflict with antivirus software. try to turn it off

play Framework MySQL and EBean

So I am trying to deploy my play Framework 2.3.5 on my Server. I have connected it with the MySQL database (newest version) and use EBean for persistence.
My 1.sql script looks like:
# --- Created by Ebean DDL
# To stop Ebean DDL generation, remove this comment and start using Evolutions
# --- !Ups
create table input (
id varchar(255) not null auto_increment,
text TEXT not null,
mode varchar(255) not null,
theme varchar(255) not null,
title varchar(255) not null,
PRIMARY KEY (id)
)
;
# --- !Downs
drop table input;
and for the reason i post this my error message:
[info] play - database [default] connected at jdbc:mysql://localhost/pastedemo
[error] play - 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 'sequence input_seq' at line 1 [ERROR:1064, SQLSTATE:42000]
Oops, cannot start the server.
#6kaijj99g: Database 'default' is in an inconsistent state!
Can someone tell me where my fault is? :)
Ok I solved the problem. It is pretty easy.
When you want to use your application in production mode, you have to delete the 1.sql. Then use activator dist for packing your application and upload it on your server. Don't test it with run again. After that you can deploy it and it works.