This question already has answers here:
mysqldump command not working?
(2 answers)
Closed 2 years ago.
I want to export large database using command line mysqldump but when i use the command mysqldump it shows blank and nothing happen.
mysqldump must be run from the regular shell, not inside the mysql program.
Type ; followed by Return to end the command you've started typing. You'll get an error because mysqldump is not a valid SQL query.
Type quite to get out of the mysql program and back to the normal command prompt.
Then type your mysqldump command line. You'll need to provide some arguments, such as the database and table names to dump.
Related
I've been searching to understanding the following MySQL command:
framework_mariadb.sql | mysql -u username -p password -h 127.0.0.1 -P 26257 target
My guess was the sql statements within the sql file get executed by mysql for the given target/database. But then I came across the source command in MySQL, ie
\bin\mysql -u root -p testdatabase < C:\Users\Juan\Desktop\databasebackup.sql
So my question is, does the first command and the second command essentially do the same thing? My apologies if this has already been asked, I haven't been able to find details for the first SQL command.
This is more about Linux shell capabilities than it is about MySQL.
The second form runs the mysql client, and uses the < symbol to tell it to take its input from the specified file.
The first form does essentially the same thing, but uses the pipe character | to indicate that the output of the first command should be sent to the input of the second command.
However, for the first form I'd expect the line to start with cat (as in cat framework_mariadb.sql | mysql ...) because the SQL script won't normally run as a shell command. cat is a command that reads one or more files and send s them to its output.
It is possible to set the SQL script up to run like this, but that requires a specific line (#! /bin/cat or similar) to be present at the top of the file, and the file must have the execution bit set. (At least, that's how I'd do it. There might be some other bash magic I'm not aware of. bash is not my forté)
There are many resources on the web that can teach the fundamentals of the Linux shell. You could try Microsoft's Introduction to bash, but there are many others.
This question already has answers here:
How to export a mysql database using Command Prompt?
(20 answers)
Closed 3 years ago.
Is there any way to export a MySQL database using MYSQL Command Line Client?
I have a database named as naukri_portal, which contains 3 tables. I am trying to export the database using MYSQL Command Line Client but it didn't work.
mysqldump -u root -p naukri_portal > naukri_portal.sql
you can use this command which will ask for a password and download your database into the current directory
mysqldump -u root -p database> dump.sql
if you are form windows use PowerShell administrator mode and if you are using Linux use Sudo command. Then run those query.
You can also follow below steps
Step -1 First download SQLyog https://sqlyog.jaleco.com/, then install it.
You will get something like
Now create a new connection for your localhost then connect to your remote database. You must remain connected to both servers together.
Step -2 Then right-click to your remote database you will get the following options.
step-3 Now click copy database to a different host then you will get another window like
step-4 Finally, select localhost and your database from the dropdown option. If you want structure and data check below option. Then click copy. The database will be copied. Due to my old version interface could be different but process will remain the same.
This question already has answers here:
How do I import an SQL file using the command line in MySQL?
(54 answers)
Closed 4 years ago.
I'm trying to restore the empty DB for mydb table but the syntax of mysqlimport doesn't seem to be straight forward. I had earlier created the file emptyDbs when doing a mysqldump.
mysqlimport mydb/var/tmp/emptyDbs
mysql statsdb < /var/tmp/emptyDbs
I am trying to extract a certain table as csv using powershell, since this task is scheduled. Since using it in Powershell is basically the same I am showing you the commandline commands I tried using:
mysql --user=root --password=root apps_monitor -e "select * from board into outfile 'C:\Temp\export.text'"
And then I get the error:
The MySQL server is running with the --secure-file-priv option so it cannot execute this statement.
My question is how I disable this option. I tried editing the my-default.ini in the MySQL Server directory and adding
secure_file_priv=NULL
And
secure_file_priv=""
But both did not do anything upon restarting the mysql service. Can someone please help me with that thing.
I created a data base using mysql. I used MySQLDump to create one database backup file in text format (MySql 5.5 on Windows XP). The database is local on my machine (local host).
I am having trouble using the MySQL command to load the dump file to restore the database. I have done the following:
Research stack overflow for how to do it. I noticed there's a bug using the MySQL command to restore the data from a post. Before I run the command, I DROP the database and CREATE the database using MySQL workbench.
I type the following command in the DOS prompt to restore the database:
mysql -u root -p -h localhost -D matlab_data -o < backup.sql
backup.sql is a the backup file in text format created by MySqlDump.
I am then asked for the password which I enter. I get the DOS prompt right away with no error message. I've waited several hours for the command to run and the database is still empty.
I have tried various command formats over the last few days. If I enter incorrect data in the command line (non existen file, database, etc), I get an error message.
I feel I would not see the DOS prompt until the database is restored. If I don't DROP and CREATE the database, I get an error message. Otherwise, not.
Does anybody have any idea what the issue is? I realize that I could be making a stupid mistake.
Thank you for your help.
shell into the mysql console and run the sql file as this
If you are already running mysql, you can execute an SQL script file using the source command or . command:
mysql> source file_name
mysql> \. file_name
note that file_name must be an absolut path