Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 80 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save iamphilrae/d538d5b48608de290bfee791df3e6f54 to your computer and use it in GitHub Desktop.
Save iamphilrae/d538d5b48608de290bfee791df3e6f54 to your computer and use it in GitHub Desktop.
phpMyAdmin Export Filename Template, Including Date and Time
@LFavier
Copy link

LFavier commented Oct 23, 2019

Thanks, exactly was I was looking for.

@zrubinrattet
Copy link

the amount of times I keep revisiting this snippet amazes me. thanks!!

@MeiRct
Copy link

MeiRct commented Oct 28, 2020

Does anyone know if it's possible to include a space character in the exported filename?

@iamphilrae
Copy link
Author

@MeiRct

Does anyone know if it's possible to include a space character in the exported filename?

Yeah that's no problem at all, just set the format to include the spaces, e.g.

@DATABASE@ %Y-%m-%d %H-%M-%S

This should output a filename of the format:

my-database-name 2020-10-28 17-01-00.sql

@mateosantosdev
Copy link

Thanks!

@andrekutianski
Copy link

Thanks!

@hbend1li
Copy link

Thanks!

@YouveGotMeowxy
Copy link

Does anyone know why the @DATABASE@ variable would be empty when doing an export?

@SERVER@ @DATABASE@__%Y-%m-%d_%H-%M-%S

results in:

mysql_3306___2022-10-30_02-00-13.sql.gz

@iamphilrae
Copy link
Author

Does anyone know why the @DATABASE@ variable would be empty when doing an export?

@SERVER@ @DATABASE@__%Y-%m-%d_%H-%M-%S

results in:

mysql_3306___2022-10-30_02-00-13.sql.gz

You could give __DB__ a try. I believe it's a legacy variable, and should output the same value as @DATABASE@, however you never know, may work.

@YouveGotMeowxy
Copy link

@iamphilrae Thank you. I just gave it a shot, but unfortunately still no luck. :/

@JorgenBB
Copy link

According to phpMyAdmin FAQ, @database@ refers to "the currently open database.
But since you are not "in" a database, it is not available.
Doesn't even work when you choose to export each database into its own file.
Weird, but that is phpMyAdmin's choice.

@YouveGotMeowxy
Copy link

@JorgenBB Ahhhh, ok, that makes some sense, thank you.

It definitely is a strange decision, or perhaps just an oversight if they've never come across the issue themselves? It seems like a pretty easy thing to add, just getting the name of the db as it iterates through the list, and add it to a variable. I'm not much of a coder or I'd try submitting a PR myself. :/

@phpmyadmin team, please add this 'enhancement', I beeeegg you! QOL improvement to the n'th degree! :)

@williamdes
Copy link

@we684123
Copy link

we684123 commented Dec 9, 2022

Thanks! ヾ(≧▽≦*)o

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment