Last active
August 11, 2021 03:42
-
-
Save PhongGCS/f10d2fcbbbcfa253cc269c1b13f0fe49 to your computer and use it in GitHub Desktop.
Mysql Command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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