Syntax error uploading a .sql file in the Command Line - mysql

In the Command Line I created a database with:
create database mysql;
but when i try to upload a database file with the command:
mysql -u root -p database < dbdump.sql;
i receive a syntax error and i don't understand where i'm wrong
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 root -p database < dbdump.sql' at line 1

confirm you're running the command from a shell and not from mysql.
I recall needing to be in mysql.exe directory when running such commands
remove the spaces around <. Ie, write mysql -u root -p database<dbdump.sql

Related

mysql ERROR 1064 (42000) when restoring mysqldump file

I created a mysql dump using code below:
sudo mysqldump --all-databases --user=root --password --master-data -create-options > alldatabase.sql
This is to migrate mysql data to a new mysql server.
Then, I tried to restore using code below:
sudo mysql -u root -p < backup.sql
but I get error:
ERROR 1064 (42000) at line 4171: 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 1
I have beat my head against the wall trying to figure this out. Any suggestions?
Both servers are Debian using 10.1.38-MariaDB-0+deb9u1
This error could appear when importing a truncated file. Please make sure that sql file is complete.
When using mysqldump like this there is no error message when disk is full.

Getting SQL syntax error while importing table into database using Mysql

I am getting the following error while trying to import the table into database using MySQL on my Ubuntu machine.
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 -u root -p spesh db_hit_type < /var/www/html/spesh.com/public_html/portal/' at line 1
I was using the following command to import the table data.
mysql -u root -p spesh db_hit_type < /var/www/html/spesh.com/public_html/portal/js/db_hit_type.sql;
I think that you try to run this command in MySQL command promt or in some client program. You need to run mysql program from server console, not from mysql console.

General server configuration WSO2 EMM

I'm almost through and I got stuck at the General Server Configuration from step 6. As in when I try the 7th step, I receive below error;
mysql> mysql -u admin -p -D EMM_DB <
/usr/local/bin/wso2emm/dbscripts/emm_mysql.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 'mysql -u admin -p -D EMM_DB <
/usr/local/bin/wso2emm/dbscripts/emm_mysql.sql' at line 1
I assume that the command I'm issuing is incorrect and if someone could clear out the issue.
Database name field, should be joined with the -D and also I would suggest to use UTF8 parameter
mysql> mysql -u admin -p -DEMM_DB --default_character_set=utf8 < /usr/local/bin/wso2emm/dbscripts/emm_mysql.sql;

Unable to create mysql database dump

I am unable to create mysql database dump. I have tried all the commands in the below question
https://stackoverflow.com/questions/24858436/unable-to-create-mysql-dump-in-mysql-server-5-6-19
But every time I get similar error which asks me to check manual
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 -pmysqlmysql hospital_management -r "c:\hosp.sql"' at line 1
I am trying these commands in Mysql command line and NOT on Windows command prompt. Also I am trying these commands before entering any database in mysql.
mysql> mysqldump -u root -pmysqlmysql hospital_management > hosp.sql
This was the first command I tried, which did not work
mysqldump is an executable, you should not run it in the MySQL command line.
Try the command
mysqldump -uroot -pmysqlmysql hospital_management > "C:\hosp.sql"
By reading the documentation, I assume that when using -r, the file must already exist.

How to properly dump mysql database via mysqldump?

Does mysqldump utility requires any seperate client ??
I'm using MYSQL5.5 command line client for windows..
I'm writing query
mysqldump -u root -p pwd** my_db > mydb.sql
I'm getting the 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 t
The problem is that you're running the command in the MySQL command line client. Run it from a shell instead, not inside of the client.
In other words, open a normal shell (cmd.exe if using Windows), and run: (your path to mysqldump.exe will no doubt differ)
C:\Program Files\MySQL\MySQL Server 5.5\bin\mysqldump -u root -ppwd** my_db > mydb.sql
Do not open up the MySQL command line client and run that command inside of there. That client is for executing SQL; the mysqldump.exe program is completely separate and runs on its own.
> not <
You're dumping the file mysql.sql INTO mysqldump, not out of it
mysqldump -u root -p pwd** my_db > mydb.sql