简体   繁体   中英

removing postgres database on ubuntu from commandline

I am working on a rails app. Due to some messing up with the code I deleted the app from my local development machine and cloned the previous commit from the git repo.

Now i want to delete the db file(postgres) of the deleted one from the local machine as well. I had issues in the past that made me unable to access several features due to database conflicts(due to same db name). So i fixed that by removing the database and recreating with the cloned app. I had done it before from commandline but i forget now on how to do it. Could some one tell me where is the postgres database file located in ubuntu or how to remove from commandline? Thanks in advance.

您可以使用postgresql shell命令dropdb

After a bit of searching i found that doing this will remove the database. From the commandline just cd into your app directory and run this command

rake RAILS_ENV='development' db:drop 

This will remove the database(although am still unable to find the exact location where its stored physically in hard drive). This is the solution if you cant access rails console, or some rake commands.

After that we can just recreate the database using

 rake db:create 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM