Exporting dump file to postgres database - nitrousio

In my Nitrous box I use a heroku postgres database as development database. Now I have a data.dump file I want to export to this postgres database. How can I do that, because it is only a database without an app on Heroku, you can't just use a pg_restore command right?

Solved it, you can use just the normal pg_restore command, but need to change the port in database.yml to 5572 (secure port)

Related

Importing Database from local disk folder to live server

Guys I am trying to import database from a folder in the laptop to a live server via putty.
I have tried using:
mysql -u root -p dbname <"c:\path to database.file.sql"
I have also tried to use:
c:\path to database mysql -u root -p <file.sql
,but all in vain saying directory not found.
How can I import database from folder in laptop direct to centos via putty command line ?
First of all you should transfer the file from your computer to your CentOS Server.
I will suggest using WinSCP, (I prefer for not large size file transfers) it is very easy to use and it can help you a lot for the files edit, too.
You should make a new connection putting your Server IP, username and password.
After that you can use drag and drop for files transfer.
You can use https://cyberduck.io/ , if you want.
For copying tables or databases from local environment to my remote server, I use SQLYog - https://code.google.com/archive/p/sqlyog/wikis/Downloads.wiki
I setup the connections to my remote environment and then to my server. Then, all you need to do is copy the database from one host to the other
Then select the remote host, database to which data should be copied and let the software do the rest of the work.

How to switch from MySQL to Postgre on Heroku

I want to host a django project on heroku. Locally, I developed it using MySQL database. And I have also pushed it to heroku but I get an Error message whenever I run heroku open command on command prompt. The error message is Can't connect to local MySQL server through socket. Though I'm a newbie in using databases, the way I understand the error is that heroku can't connect to local MySQL server which I'm using for local development. I don't want to connect to a remote MySQL database, instead, I want to connect to Postgre database just as heroku recommended.
Being a newbie in the use of database, I don't know the best way to migrate to Postgre or how to add MySQL in my project to .gitignore. Is it possible for me to start running Postgre on heroku while MySQL isn't added to . gitignore and is still the database in settings.py? Must I clear MySQL database or add it to gitignore before I can use Postgre?
PostgreSQL settings for Heroku:
Please install dj_database_url using below command:
pip install dj-database-url
In settings.py , import dj_database_url and add below settings at the end of the file:
import dj_database_url
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
Done !! Now, deploy again to Heroku.

Restore .sql export to WordPress db from within WordPress?

I've been developing a client's site and have maintained .sql backups using Export of phpMyAdmin. Yesterday my client provided me with credentials for the destination server and asked if I could migrate the development site to the beta site.
I can copy the files, of course, and I have changed wp-config.php to point to the new database correctly. When I load the page initially a default WordPress installation is created.
Unfortunately, I was not provided cPanel or phpMyAdmin credentials.
Ideally, there would be a plugin or script that would drop all of the existing tables created by default and use my .sql export to recreate the tables and populate them with data.
Does anyone know if there is a way to import this .sql from within WordPress?
You can import it with mysql on the command line:
mysql -u someuser -p password <yoursqlfile.sql
Or you can open it in mysql workbench (download from mysql.com) and run it from there.
In case you cannot SSH to the server or access the database via workbench as Norbert suggested, you can try XCloner.
It would be better if you had some sort of direct access to the database, but I'm guessing if you do not have cpanel access you also do not have SSH access. It is also common for databases to be restricted to local access, so a remote connection via MySQL Workbench may not be an option.
If for whatever reason none of these solutions work, you can temporarily connect the site to a remote database that you have access to until you get the necessary credentials from the client.

How do I export a MySQL database from PHPMyAdmin and import it to SQLite?

I would like to export a database from PHPMyAdmin (or MySQl Workbench) and import it to a SQLite database so that I can do local editing and testing without screwing up the live version. I am very new to SQL, so all of the export options, etc, are rather dense to me at this point. I have tried using the default export settings PHPMyAdmin with the command
sqlite3 test_db.db < maindb.sql
as well as
sqlite3--> .read maindb.sql
But these throw a bunch of syntax errors and 'no such table' errors.
I have also tried the oft-cited script script found here, but when I try to run this using an export from MySQL Workbench, using the command:
943776/mysql2sqlite.sh maindb.sql | sqlite3 test_db.sqlite
I get the following error:
mysqldump: Got error: 2002: Can't connect to local MySQL server through socket '/var/run/mysql.sock' (2) when trying to connect
Am I not configuring the exports correctly?
Please see that the referenced script connects to the database server itself. It does not expect a dump!
./mysql2sqlite -h example.com -u root -pMySecretPassWord myDbase | sqlite3 database.sqlite
This is the way the script should be executed. With host, username, passwort and the mysql database you would like to dump.
Since database dumps and DBMS features can be severely different between different DBMS (like MySQL and sqlite3), I would recommend to install a local MySQL server instead of using sqlite3. What advantage have you achieved when you make changes to sqlite3, which you cannot apply to the MySQL production database without changes?
An alternative solution is to export an sql dump of your database and then import it back into phpLiteAdmin. From there you can manage your sqlite database inside your browser. When you want to export it, just open the folder where the database is stored and copy the database file.
This solution does not require messing around with scripts, and it's especially handy if you're on a Mac and you're using MAMP, since phpLiteAdmin comes preinstalled with it.

Created a mysql database but can't seem to find it anywhere

I just cloned a repo from github and bundle installed everything and created a mysql db via rake db:create. I migrated the database and everything....however, I have no idea where it is located? Usually when I use sqlite, it's in the db/ folder...but this database is not. where can I find it?
Look in your MySQL config file. Usually it's called my.cnf. Where to find this config on your system, we can't say :-)
Look for datadir in a config file
[mysqld]
datadir=/var/lib/mysql/
MySQL works a bit differently than sqlite. Whereas sqlite writes a database directly to a file (in your db/ directory in the case of rails), MySQL writes it to a server (usually located on the same machine as your application, but not always). I would be surprised if an app you cloned off of github let you create a mysql database right off the bat. You need to set up a mysql server and set a password for it. If you're running Ubuntu -- as I am -- these are some good instructions. Then you need to configure your config/database.yml file accordingly.