2

Is there a way to run a backup of a mysql database using sql? We have scripts which run updates against our databases. They only have mysql user credentials, not system login credentials.

Is there anyway to run backups of mysql via a mysql connection instead?

1
  • mysqldump itself simply connects to the server, executes SQL queries to fetch the data, and formats the output as a SQL script, ready for importing later. You can look at the nysqldump source, see the queries it executes, and write it again, except why, given that mysqldump already exists? mysqldump works with any kind of credentials, and can be used to dump only specific tables in the database that you have access to.
    – fds
    Commented Jan 17, 2020 at 4:45

3 Answers 3

1

Is there a way to run a backup of a mysql database using sql?

Short answer: No.

... scripts ... only have mysql user credentials, not system login credentials.

I'm pretty sure it's possible to run the mysqldump utility against a remote database.

However, I would have to ask "Why?"

Even if you could take a backup, what would you hope to do with it?

It seems to me that you don't have the tools or the credentials necessary to take proper backups (or to restore a database, which pretty much has to be done on the machine itself). As such, I would guess that someone else is responsible for keeping these databases up and running, recoverable and well-tuned (at least I hope so, or your organisation is in Big Trouble).

Perhaps you should discuss options with them?

0

I think you are looking for

select ... into outfile

https://dev.mysql.com/doc/refman/5.7/en/select-into.html

-3

You can try using the built in OS backup software. Been a while, but I think I used to do it with Windows backup many years ago

2
  • 2
    I'm looking for a way to start a backup job using a sql command. I'm not sure how your answer is related to the question.
    – bpeikes
    Commented Jun 2, 2018 at 15:34
  • An Operating System backup is generally not suitable for backing up a running database. Database != File.
    – Phill W.
    Commented Feb 17, 2020 at 12:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.