Skip to content

Instantly share code, notes, and snippets.

@ArsSirek
Last active May 4, 2017 21:10
Show Gist options
  • Save ArsSirek/1b3dea28ddf2cea58243 to your computer and use it in GitHub Desktop.
Save ArsSirek/1b3dea28ddf2cea58243 to your computer and use it in GitHub Desktop.
command line mysql database import from file (like phpmyadmin export)
mysql -u username -p -h localhost
# > in sql command line
# Attention!! this will ERASE database from server
# Be sure that you know what are you doing
DROP DATABASE database_name;
CREATE DATABASE database_name;
ALTER DATABASE database_name charset=utf8mb4;
#create user if needed
CREATE USER 'user_name'@'localhost' IDENTIFIED BY 'pwd';
GRANT ALL PRIVILEGES ON database_name.* TO user_name@localhost;
# executes sql command from file (import from phpmyadmin defualt export)
mysql -u username -p database_name < file.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment