Skip to content

Instantly share code, notes, and snippets.

@ErDmKo
Last active July 20, 2018 11:42
Show Gist options
  • Save ErDmKo/7430412 to your computer and use it in GitHub Desktop.
Save ErDmKo/7430412 to your computer and use it in GitHub Desktop.
Sql create new database and create user.
CREATE DATABASE <BDname> CHARACTER SET utf8 COLLATE utf8_general_ci;
GRANT ALL PRIVILEGES ON <BDname>.* to <user_name>@localhost identified by '<user_password>';
for crone:
mysqldump -u <user_name> '-p<user_password>' <oldBDname> | gzip > ~/$(date +/var/sqlDump/<oldBDname>.sql.%Y%m%d.gz)
gunzip < `date +/var/sqlDump/<oldBDname>.sql.%Y%m%d.gz` | mysql -u <user_name> '-p<user_password>' <BDname>
CREATE USER <un> WITH PASSWORD '<up>';
CREATE DATABASE sales ENCODING 'utf8' OWNER <un>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment