Loading mysql file to rds database in AWS - mysql

I have database inside aws ec2 instance. I like to transfer that ec2 instance's database to rds database.
From Phpmyadmin, database.sql file is exported firstly.
I have that file database.sql copied to the instance's ~/ folder.
Then login to mysql as
mysql -h database.cqqqzagkqjoe.ap-southeast-1.rds.amazonaws.com -P 3306 -u testdatabase -p
Then the database.sql file was imported as
mysql> mysql -u username -p database < database.sql
After that I got error as
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 'mysql -u username -p database < database.sql' at line 1
What is wrong with that message?

Do not log into the MySQL server as client, execute the SQL file.
So, from the EC2 instance itself:
mysql -h database.cqqqzagkqjoe.ap-southeast-1.rds.amazonaws.com -u testdatabase -p < database.sql

Related

Getting syntax error while exporting mysql database

I have cPanel trial version installed on the centOS server which is expired now. So I don't have access to cPanel user and WHM login.
I am tried the following
mysql> mysqldump -u root –ppassword db_name > db_nametext.sql;
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 mysqldump -u root –ppassword db_name > db_name at line 1
Thank you for time and consideration.
You cannot run mysqldump from mysql shell: mysqldump is not a SQL statement but an executable that must be run from linux shell like mysql command.

How to mysqlimport a local export to remote mysql server?

I have a local mysql dump that I want to copy-insert into a remote db:
mysqlimport --host=192.168.xxx.xxx --user=username --password=password remote_table /tmp/export.txt
Result:
mysqlimport: Error: 1290, The MySQL server is running with the --secure-file-priv option so it cannot execute this statement
So how can I tell my remote mysql server to accept imports from remote machine?
i) take mysql dump as follows
mysqldump -u user -p db-name > db-name.out
ii) Copy db-name.out file using sftp/ssh to remote MySQL server:
scp db-name.out user#remote.box.com:/remoteBoxDirectory
iii)Restore database at remote server (login over ssh):
mysql -u user -p db-name < db-name.out
or
mysql -u user -p 'password' db-name < db-name.out

mysql: unable to use mysqldump on production

I tried below commands,
mysqldump -h 127.0.0.1 -u username -p db_name > dumpfile.sql;
mysqldump -u username -p password db_name > dumpfile.sql;
mysqldump db_name > dumpfile.sql;
It always throw this 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 'mysqldump ..' at line 1
mysql version: 5.7
You should launch this command from CLI as it's a separate binary executable. According to the message you get you trying to execute it as SQL command and it's totally incorrect.

How to export .sql file in MySQL database using MySQL commandline client?

How to MySQL server database export .sql file using command line?
I have used below commands,but shows in syntax error
mysqldump -h ipaddress -u username -p password> mysqlfile.sql
I have below 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 'mysq
dump -h 192.268.1.17 -u root -p root> mysqlfile.sql' at line 1

backup the database using MySql

hi i want to backup my MySql database,
i write this command :
mysqldump -u root -ppassword -h localhost --all-databases > backup.sql;
and it give this 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 'mysql
dump -u root -pmanager -h localhost --all-databases > backup.sql' at line 1
why?
and what should be do?
thanks...
You are running this command in mysql. You should be running it from the command line instead.