-
Into the local database
1
psql resumehack_development
-
Enter the database server
console directly connected to the database bin / rails dbconsole production -
Modify the database password
password -
View database size
command:
1
SELECT pg_size_pretty(pg_database_size('database name'));
All queries and tables are arranged according to size
1 |
select table_name, pg_relation_size(quote_ident(table_name)) from information_schema.tables where table_schema = 'public' order by 2; |
- Single copy table data
pg_dump -U postgres -table jd_temps -Fc test_production> /home/apps/jd_temps.sql
scp [email protected]:/home/apps/jd_temps.sql /Users/dailanyi/Downloads/
psql resumehack_development
DROP TABLE jd_temps;
pg_restore -U dailanyi –dbname resumehack_development –table=jd_temps /Users/dailanyi/Downloads/jd_temps.sql
psql resumehack_development
ALTER TABLE jd_temps ADD PRIMARY KEY (id);
-
Imported to the local database
1
psql resumehack_development < /Users/dailanyi/Desktop/PostgreSQL.sql
-
restore db
1
2psql -U postgres -d wondercv_test -c "drop schema public cascade; create schema public;"
psql --set ON_ERROR_STOP=on -U postgres wondercv_test < #{db_unzip_file}
mysql
Database from local to remote copy
1. First check whether the remote backup file
is not created a:
mysqldump-uroot--p password database name> guided by the document name database .sql
2. locally run
scp -P port number root @ server name: / opt / app / Process Name / current / lead out of the database file name .sql.
3. The remote copy down the database backup documents poured into the local database
mysql -uroot -p local database password for the local database name <guided by the document name database .sql
ps:
-
Remote Download:
1
scp -r [email protected]:/home/apps/main-backup/resumehack_pg/2018.12.02.15.30.02 /Users/dailanyi/Downloads/
-
Upload documents to a local server
1
scp /path/local_filename username@servername:/path
-
In the documentation directory is not run inside the console
Export RAILS_ENV = Production's
Rails Runner /home/apps/download_interview_data.rb
Original link large column https://www.dazhuanlan.com/2019/08/15/5d5514081e2ac/