SQL dump and import
PostgreSQL
Install
macOS
brew install postgresql
brew services start postgresql # 启动服务
brew services stop postgresql # 停止服务
Ubuntu
sudo apt update
sudo apt-get install postgresql
sudo systemctl status postgresql
sudo -u postgres psql
Dump
pg_dump mydb > db.sql
Import
pg_dump -t mytable mydb > table.sql
MySQL
Install
macOS
brew install mysql
brew services start mysql # 启动服务
brew services stop mysql # 停止服务
Ubuntu
sudo apt update
sudo apt-get install mysql-server
sudo systemctl start mysql
Dump
mysqldump -d <database> -u<user_name> -h <host> -p > backup.sql
Import
mysql -u <user_name> -h <host> -D <database> -p < backup.sql