How can I drop a database from MAMP using the command line - command-line

Can someone help me with a command line instruction to drop a single MAMP database?
Thank you

Run /Applications/MAMP/Library/bin/mysql -uroot -p. It'll ask for your password. Then just use the regular MySQL DROP DATABASE nameofdatabase command.

Related

How can remove PostgreSQL with all configuration and intial data from Manjaro?

I want to remove PostgreSQL with all initial data and configuration. Because, postgres user has default password and I do not know what is it.
Thanks for any help.
The following command worked for me
sudo pacman -Rcns postgresql

Error while using createdb command postgresql on windows 10

I am a new user of PostgreSQL, and I am learning it so that I can use it with Django, so I am trying to use the createdb command to create a new database, but even though I am entering the correct password for my account, I am getting this error. I reinstalled everything and checked everything I could think of but I was not able to solve this error. So, if I can get some help regarding this issue it would be nice.
Even using the command psql, and submitting the correct password, gives the same error.
I am using Windows 10.
As far as I checked, I needed to enter the password I used while installing PostgreSQL.
By the way, I am using the latest version of PostgreSQL 14.1
The command I used:
createdb testdatabase
createdb: error: connection to server at "localhost" (::1), port 5432 failed:
FATAL: password authentication failed for user "<username_placeholder>"
So, basically, I figured the solution myself. I am just posting it here because mostly answers are available for Linux and not Windows. So, if a windows user has a similar problem, maybe this answer could help them.
So, the first thing is, if you need to open psql, use the command:
psql -U postgres
and then enter the password you used while installing PostgreSQL. Now, if you wish to do something similar to what I tried, what I mean is to use createdb command in the terminal itself, then you will have to create a new user using the same username as you do for your PC, like in my case, it is aryan.
(For example: C:\Users\aryan\).
I followed instructions from this website.
I personally used pgAdmin 4 to do it, you could also use the SQL commands themselves.
After doing everything, when I used the createdb command directly from the terminal/powershell, it asked my the password which I had used to create the other user( with the same username as my system/pc) using pgAdmin 4. That's it. This helped me out.

Unable to create new Postgres database

I'm unable to create a new database for the first time after installing postgres.app on my macbook pro
Anyone here can point me to the origin of the problem ?
createdb is not a SQL statement, it's program for the command line (like psql or grep).
Inside psql you need to use the SQL statement CREATE DATABASE:
http://www.postgresql.org/docs/current/static/sql-createdatabase.html
And don't forget to terminate every SQL statement with a ; (if you had done that with createdb you would have gotten an error message immediately).

Heroku pg:pull is giving sh: createdb: command not found

When I try to do heroku pg:pull DATABASE_URL myappspassword, I get this error:
my-computer:a-folder (master*) · heroku pg:pull DATABASE_URL myappspassword
! sh: createdb: command not found
!
! Unable to create new local database. Ensure your local Postgres is working and try again.
For once Googling doesn't return a result. I'm wondering if it's related to the fact that when I do which psql, there is no result. Maybe I need to do something special with pgAdmin to get this working (e.g. export command line tools)?
Are you on a Mac, by chance, and using Postgres App?
If so, the problem might be that createdb isn't on your path. Try adding it by inserting the following into ~/.bash_profile.
export PATH=$PATH:/Applications/Postgres.app/Contents/Versions/9.4/bin
Then run source ~/.bash_profile and try again.
There's more info on the Postgres App site: http://postgresapp.com/documentation/cli-tools.html
Your instincts are correct. You need to be able to access the Postgres from your command line. pg:pull is attempting to create a new local database and drop the relevant data from your Heroku database into it. From the docs:
This command will create a new local database named “mylocaldb” and then pull data from database at DATABASE_URL...
Basically, your local machine is trying to run createdb locally but your terminal isn't recognizing it.
I battled this damn error for a few hours. I can't say for certain if this will work for everyone but I found my issue stemmed from running the command via iTerm/ZSH instead of just normal bash. I opened up plain-old vanilla terminal, ran the command, and everything fired off like it should.

mysqldump created dump is uncomplete

A TYPO3 installation has 57 tables in it's database named typo3.
Creating a dump using the mysqldump program by the command
mysqldump --host=127.0.0.1 --password=<PASSWORD> --protocol=tcp --port=3306 --user=<ROOT-USER> --lock-all-tables --databases typo3 > dump.sql
contains only 47 tables.
The same result occurs if the database connection is done via socket and also if the "--lock-all-tables" option is left out.
How to make a complete dump containing all the tables?
The missing tables are
index_config
index_debug
index_fulltext
index_grlist
index_phash
index_rel
index_section
index_stat_search
index_stat_word
index_words
I'm not sure, why all the index_* tables are not dumped with mysqldump, but I can suggest you to use SypexDumper. In most of the cases, when mysqldump or phpMyAdmin dumps were not possible, it saved my day.
I use this for dumping: mysqldump -u server_dbuser -p -h localhost server_db > dbdump.sql
Have you tried from phpmyadmin?
Are the index_ tables needed, or can the be rebuilt anytime anyway?
Thanks to Urs and Viktor Livakivskyi for their intention to help! The problem was caused by an individual script triggered by cron.