Skip to content

Instantly share code, notes, and snippets.

@PhongGCS
Last active August 11, 2021 03:42
Show Gist options
  • Save PhongGCS/f10d2fcbbbcfa253cc269c1b13f0fe49 to your computer and use it in GitHub Desktop.
Save PhongGCS/f10d2fcbbbcfa253cc269c1b13f0fe49 to your computer and use it in GitHub Desktop.
Mysql Command
// Create new user, new db and grant privilege
> CREATE USER 'phong'@'localhost' IDENTIFIED BY 'phong!';
> CREATE DATABASE phong
> GRANT ALL PRIVILEGES ON phong.* TO 'phong'@'localhost';
> FLUSH PRIVILEGES
// Check size all db
> SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema
// Import DB
$ mysql -u user -p phong < file.sql
// Import multiple db
$ mysql -u user -p < file.sql
// start brew mysql in MacOs
brew services start mysql
// stop brew mysql in MacOs
brew services start mysql
// Import DB from file
sudo mysqldump -u phong -p phongdatabase > file.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment