mysqldump error while copying database from server to another - mysql

I'm trying to copy database from one server to another like this
mysqldump -u<source_db_username> -p<source_db_password> -h<source_db_ip_address> source_database_name
| mysql -u<target_db_username> -p<target_db_password> -h<aws_rds_endpoint> <aws_rds_db_name>;
But I get
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 'mysqldump -u<source_db_username> -p<source_db_password>
-h<source_db_ip_address> source_database_name ' at line 1

I shouldn't use the database while copying I just have to refer the mysql location to use it and shouldn't use ';' at the end of the command it's working now.

Related

"BACKUP" is not valid at this position

I'm creating how to create a Database and made a very simple code following W3Schools tutorials, however I can't seem to backup my database.
CREATE DATABASE testdb
BACKUP DATABASE testdb
TO DISK = 'E:\database';
I get this error:
"BACKUP" is not valid at this position, expecting EOF, ';'
13:19:03 CREATE DATABASE testdb BACKUP DATABASE testdb TO DISK = 'E:\'; Error Code: 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 'BACKUP DATABASE testdb TO DISK = 'E:\'' at line 2 0.000 sec
I tried to do it step by step, all together (as shown above), etc, but I always get this error.
Thank you!
Such a comand doesn't exists in mysql
see manual what us possible in MySQL like OUTFILE and mysqldump
You problably copied this form another rdms

Create database in SQL and get an error but everything right

I try to install fleetspeak. Use Ubuntu 18.04.
First of all I run this
CREATE USER 'fleetspeak-user' IDENTIFIED BY 'fleetspeak-password';
Then I want to create database with this
CREATE DATABASE 'fleetspeak';
But has an error:
ERROR 1064 (42000): 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 ''fleetspeak'' at line 1
Why I can get this?
Try the create database script without single quotes in dbname
CREATE DATABASE fleetspeak;

MySQL commands not working in phpMyAdmin

I am able to create databases and tables using the User Interface in phpMyAdmin , but when I do the same using MySQL commands , It does not work. I get this error :
SQL query:
DROP DATABASE 'alphacrm'
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 ''alphacrm'' at line 1**
don't use quote
DROP DATABASE alphacrm;
my sql object don't need quotes eventually use backtics for reversed word and compite named eg:
`my obj`

Backwards compatible mysql dump

I am trying to port a database from mysql 5.7 to mysql 5.5.
At first, I used the following command
mysqldump -u root -p --all-databases > alldbs.sql
When I try to import the DB in mysql 5.5 I keep getting errors like
ERROR 1064 (42000) at line 572: 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 'STATS_PERSISTENT=0' at line 9
where it complains about STATS_PERSISTENT=0 statement.
Then I tried
mysqldump -u root -p --compatible=mysql40 --all-databases > alldbs.sql
but this just gives me
ERROR 1064 (42000) at line 26: 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 'TYPE=InnoDB' at line 22
where it complains about TYPE=InnoDB statement, which should be ENGINGE=InnoDB. Even with the --compatible option it still keeps the STATS_PERSISTENT statement.
Is there a way to port a mysql 5.7 database to mysql 5.5?
UPDATE
To be clear on my question, I am looking for relialble, i.e. no-hack way, to port the database. I already tried to replace TYPE with ENGINE, remove STATS_PERSISTENT etc. Something else always came up. I am not willing to jump through those hoops everytime I port the database. I am looking for a reliable way via mysqldump or a similiar tool to do the job.
If this is not possible then I will have to switch to an alternative DB.

MySQL dump compatibility issue (from 4.0.26 into 5.5.41)

I am trying to transfer data from MySQL 4.0.26 into MySQL 5.5.41-0ubuntu0.12.04.1.
I am making a dump from MySQL 5.5 server via mysqldump it works but when I'm trying to restore it there a problem occures:
ERROR 1064 (42000) at line 20: 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 'TYPE=MyISAM' at line 4
Is there some way how to create compatible dump for MySQL 5.5. from MySQL 4.0?
This should work
mysqldump ... | sed 's/TYPE=/ENGINE=/g' | > dump_file
(...and be enough. In the link Jens posted, there's another substitute for timestamp(14), but MySQL does this automatically, if I'm not mistaken.)