I want to make a backup of a db in mariaDB, I've used the following statements but any work.
mysqldump -u root -p -databases messages > dbdescargada.sql
mysqldump -u root -p messages > dbdescargada.sql
mysqldump -u root messages > clients.sql
mysqldump --user='root' --add-locks messages messages > copia.sql
mysqldump --user='root' --add-locks messages messages > copia.sql
But all showed the same error:
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 'statement' at line 1
I really need to do this backup cause I need to make important changes to the tables structures,
I'm using Xampp for Linux, Ubuntu 20.04
I know I can do it from localhost/phpmyadmin but I need also a code option
You have 2 problems:
1) You are running it from mysql CLI. mysqldump is a shell command, not a mysql command.
2) Lose the - in -> redirect to file - there is no minus before >
The parameter is --databases
Your images suggests that you run the shell command in the mysqlshell that is wrong, yoz must run it in a normal command window bash msdods...
Please check the parameters
mysqldump -u root -p --databases messages > dbdescargada.sql
Related
I want to create/export only the stored procedures from my Google Cloud SQL DB. I tried several commands on my phpmyadmin(installed on Google App Engine) console but I am consistently facing the error mentioned below.
List of commands I've tried:
1. mysqldump --routines=true -u root sarda_yogi_mobile > my_database.sql
2. mysqldump --databases database_name [-h instance-ip -u username -p password] \ --hex-blob --default-character-set=utf8 > database_file.sql
3. mysqldump --databases database_name [-h instance-ip -u username -p password] --default-character-set=utf8 > database_file.sql
4. mysqldump --host="127.0.0.1" --user="root" --password="" --routines --triggers --events dbname > my_file.sql
Error Message:
#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 'mysqldump --routines=true -u root db_name > my_database.sql' at line 1
Can anyone point me in the right direction? Thank You :)
As #Vadim said, you're attempting command-line statements at a SQL shell, which (as you've seen) doesn't work.
To perform a stored procedure export from within phpMyAdmin, go to the "Routines" tab of your database and click "Export" for the routine you wish to export. You could instead use the checkboxes to select several to export at once, if you prefer.
Those are commands you need to run on a command line, not via the phpMyAdmin shell.
If you want to perform an export from phpMyAdmin, there are some guides available on the web, e.g. http://www.inmotionhosting.com/support/website/phpmyadmin/export-database-using-phpmyadmin
I am trying to restore a mysql db using a .sql.gz file. I am using mySql console to run a command because file size is too large for phpMyAdmin. Command I am using is
gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
where root is the user id. There is no password for root. bd is the database to which I am trying to import. mysql is running on my local machine (Windows 8). I have a wamp setup.
This is the error I am getting:
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 'gunzip
C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql | mysql -u root
-p' at line 1.
You need -c option (output to stdout)
gunzip -c xxx.sql.gz |mysql -u root -p
While Kisoft´s answer is the correct one, I just wanted to point out that you don´t need the -c, it works just fine as it is.
this command will unzip the database dump and import it into the database at the same time.
gunzip < output.sql.gz | mysql -u <username> -p<password> <database>
If you type gunzip and you get a SQL syntax error that complaints about gunzip, you are already logged into the mysql console. The mysql console is not a general purpose shell!
You are using Windows and I suspect you haven't installed gzip in your computer (it isn't a builtin utility). It's a classical Unix tool but you can find binaries for Windows. Install it and run your original command with a couple of tweaks:
Make sure you're in Windows prompt (C:\>)
Redirect gunzip result to stdout rather than a file:
gunzip --stdout C:/Vik/Gya/Source/beed_2013-04-06.sql.gz | mysql -u root -p bd
Alternatively, you can run the dump from within MySQL promt (mysql>) if you uncompress it first (you don't need specifically command-line gzip, most GUI archivers such as 7-Zip support this format):
mysql> \. C:/Vikalp/Gyankosh/Source/beedictionary_2013-04-06.sql
you do not need to gunzip
just:
zcat myfile.gz | mysql -uuser -ppassword mydatabase
it is faster this way
Your answer is already here
phpMyAdmin: Can't import huge database file, any suggestions?
Under php.ini file, normally located in c:\xampp\php or wampp whatever you called
post_max_size=128M
upload_max_filesize=128M
Changing value there will get you what you want.Good luck
Dont forget to restart , apache and mysql .
Try this following steps to restore db using .gz files:
1. Run command : gunzip C:/Vik/Gya/Source/beed_2013-04-06.sql.gz
This will uncompress the .gz file and will just store beed_2013-04-06.sql in the same location.
2. Type the following command to import sql data file:
mysql -u username -p bd < C:/Vik/Gya/Source/beed_2013-04-06.sql
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
This is the command I used:
mysql> mysql -u root -p -h HOST sample < mysqldump.sql;
But I encountered an error as follows:
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 -h HOST sample < mysqldump.sql' at line 1
Hope you can help me out?
That's the command you should give in the command line, not in MySQL itself.
Open mysql terminal or konsole and then go to the directory where mysqldump.sql file is present. try:
shell> cd /file_path/;
shell> ls -al mysqldump.sql;
It should display your file. Also you dont need to specify HOST if you are logged on to the same server.
shell> mysql -u root -p sample < mysqldump.sql;
from client you can run \. mysqldump.sql but i think first variant is preferable.
I'm having some difficulty with mysqldump. I locked my tables and ran the following command:
mysqldump -u user -p password databasename using my actual password and database name.
When I run this from mysql I get a 1064 error that says there is an issue with my syntax. I've also tried running the command from terminal (outside of mysql) and receive a 'command not found' error message. I'm not entirely sure how I should be doing this (the explanations I've found so far have been vague).
Thanks for the help.
The mysqldump is a program, it cannot be executed from the mysql console. Run it from the shell.
Have a look at the syntax reference.
--user=user_name, -u user_name
--password[=password], -p[password]
As you see there is no space between -p and password. So, your command line should be like this:
>shell mysqldump -u <user_name> -p<user_password> ...
or
>shell mysqldump --user=<user_name> --password=<user_password> ...
You are missing the target backup file name:
# [mysql dir]/bin/mysqldump -u username -p password --databases databasename > /tmp/databasename.sql
MySQL Commands
the correct syntax is
mysqldump -u [username] -p[password] [databasename] > [backupfile.sql]
you should add the > backupfile.sql
the other error is believe your system doesn't recognize the mysqldump path and you should go directly to bin folder from mysql installation.