Access Denied for User ODBC - cmd

i installed Mysql on Windows 7, i used mysql with mysql command line client & i also use Mysqldump in windows cmd, it was working without any problem.
But today, i tried to export database using mysqldump with this command in cmd
mysqldump –u root -p mypassword db_name > f:\mydb.sql
i tried many other commands and i always see error
Access Denied for User 'ODBC'#'localhost' (using password: yes) when trying to connect
as you can see, in mysqldump command i am using root as user then why i get user ODBC error ? one more thing, using mysql command line client i am still using mysql normally without any problem using root as user. Thanks

Related

psql: error: could not connect to server: FATAL: password authentication failed for user

I have successfully installed postgresql and added path to my environment variable in windows 10. But the problem is when i try to run psql postgresql in command prompt it gives error saying
C:\Users\adity>psql postgres
Password for user adity:
psql: error: could not connect to server: FATAL: password authentication failed for user "adity"
I am 100% sure my password is correct I have tried reinstalling and uninstalling many time in case i missed password but every time it gives me same error. Although when i try to run from GUI it starts running. This is frustrating and I am not sure what the problem is.
The database superuser that was created during database cluster creation is very likely called postgres.
So rather than using the default, which is to use the database user whose name is the same as your current operating system user, explicitly specify the database user postgres:
psql -U postgres

Windows: how can I set my PostgreSQL user to the superuser?

I am trying to create a database using PostgreSQL 9.4. I type "psql" in the command prompt, and then it asks for a password. I provide the password I set during the installation, but it says the authentication failed. After checking online, I concluded that I need to be using the superuser, named "postgres", which is the system user whose password is the one I set during the installation.
I am now trying to set PostgreSQL to this superuser. I spent a lot of time surfing the internet for a solution but wasn't able to solve the problem. I tried postgres ALTER USER myuser WITH SUPERUSER (I wrote that in the Windows command prompt), but it said that "alter" isn't recognized. Now, when I try to use PostgreSQL, my main problem is that I get the error: "role MYUSERNAME does not exist". (this is after I edited pg_hba.conf to make it not ask for a password)
By default, psql uses the name of the operating system to log in, to a database of the same name. If you want to log in as user postgres you should do:
psql -u postgres <any other options>
If a password is asked for, you give the password of the postgres user. You are now connected to the postgres database, where you really shouldn't be doing anything, except create new users (which are global to the installation) and other databases.
Once in the console, you can create new users like:
CREATE ROLE myusername LOGIN PASSWORD secret;
And new databases like:
CREATE DATABASE myowndb;
ALTER DATABASE myowndb OWNER TO myusername;
Then you log out from the console with \q.
In order to be able to access PostgreSQL using the new database, you have to edit the pg_hba.conf file (sample, modify to match your network settings):
host myowndb myusername 192.168.0.0/16 md5
Now you restart the PostgreSQL server from the Services tab in Administrative tools on the Control Panel.
Then you can log in to your new database:
psql -u myusername -d myowndb
Or use other clients like pgAdminIII.
Under Windows. The Postgres bin directory ships with the user commands createuser.exe and dropuser.exe.
Say, if running initdb (effective fresh install) or for some other reason there is no superuser (like the question).
Can also manage the users and superusers (-s option) with the above two commands. ie.
Create the superuser called postgres:
C:"Program Files"\PostgreSQL\15\bin\createuser.exe -s postgres
Drop a user:
C:"Program Files"\PostgreSQL\15\bin\dropuser.exe postgres

PostgreSQL keeps prompting for a password I never gave in PowerShell

I'm trying to set up postgresql to run locally on my windows machine. I've downloaded psql from postgresql.org and installed it. However, whenever I try to run the psql command from the command line it prompts me for a password that I never gave it for a user it seems to have automatically generated based on the user name of my computer.
In Powershell:
PS C:\Users\Theophilus> psql
Password:
psql: FATAL: password authentication failed for user "Theophilus"
Nothing I would use as a password works in this case. I've uninstalled and reinstalled postgres from my windows machine to see if maybe there was somewhere to input a password but I found nothing.
Additionally, running psql with the default username of 'postgres' results in the same problem.
PS C:\Users\Theophilus> psql -U postgres
Password for user postgres:
psql: FATAL: password authentication failed for user "postgres"
Hopefully someone can help me.
That's because you're not providing a username in the command so it's using your current username that you're logged in as which doesn't have permission. You should use the postgres account.
c:\path\to\psql.exe -U postgres
So in your case
PS C:\Users\Theophilus> psql -U postgres
https://wiki.postgresql.org/wiki/First_steps

What is the default password for Postgres

I have just install Postgres 9.3 on Windows 7. The installation completed successfully. It has never asked me to provide the password for postgres user.
The service postgresql-x64-9.3 is up and running. However, I cannot connect: I do not not know the password. I've found the following answer, but it did not help:
similar question on Ubuntu
[LINUX]
might work for windows too
After installing postgres follow following steps in order to setup password for default system account of Linux execute following in terminal:
user:~$ sudo -i -u postgres
postgres#user:~$ psql
after executing above two commands you will get into postgres shell
Execute this query in postgres shell:
postgres=# ALTER USER postgres PASSWORD 'mynewpassword';
your new password is 'mynewpassword' without quotes and now you can connect with external GUI tools like DBeaver
WARNING: trust means exactly that. Anyone who can connect to the PostgreSQL server can control it. If you set trust mode that allows superusers like user postgres (or all users) to connect, they get total control of your PostgreSQL and can probably run shell commands too. You should usually only use it to change the password then restore the configuration back to the auth mode you were using before.
If you used an unattended installer script, the password will be in the script or associated config file.
Otherwise, treat it the same as if you lost/forgot the password rather than never knowing it:
Edit pg_hba.conf, setting the auth mode to trust instead of the default md5
In the Services control panel restart the PostgreSQL service
Connect with psql or PgAdmin or whatever
ALTER USER postgres PASSWORD 'mynewpassword';
Edit pg_hba.conf again and set the auth mode back to md5
Restart PostgreSQL again
pg_hba.conf is in your data directory. By default it'll be %PROGRAMFILES%\PostgreSQL\9.3\data.
To edit it you'll have to use the security tab to give yourself read/write permissions (via a UAC prompt). This might require you to set yourself as the owner of the file.
On unix systems it's more secure to prepend a
local all all peer
line to pg_hba.conf and then sudo -u postgres psql (assuming your PostgreSQL server runs as user postgres) to get an interactive psql session without using a password. That way you don't have to use trust.
On initialisation you can access the DB as:
Username: postgres
Password: postgres
By default user postgres does not have a password
Start psql and create a password:
sudo -u postgres psql
\password postgres - It will ask you enter a password for user postgres
Through trial and error I found that the password for Postgre SQL 10 for the username postgres is "admin". I kept typing in different password until I reached that password. I am using pgAdmin 4 to test out my SQL Statements, POSTGRE SQL 10 is the first server connection set up using localhost.
It seems there was no default password, but psql wouldn't accept a lack of a password (fe_sendauth: no password supplied). To get around this, I opened pgAdmin, then in the left sidebar:
Servers
Login/Group Roles
Right click postgres and click Properties,
Go to Definition tab
Set the password in the Password field
After saving, psql accepted that password. There may have been a switch I could have supplied to have it accept a lack of a password (--no-password?), but the user should probably have a password anyways, so this seemed reasonable.
go to control >> computer management >> Locaol users and group >> users >>
right click on openpgsvc >> set password.
after that now you can access with this password on openpgsvc
The simplest solution I've found is just to install PgAdmin and connect to the local server with the current Windows credentials (username + password). Then you can change the password to the postgres user.
step1: Go to control panel
Step2: Click on Administrative Tools
Step3: Click on Computer Management
Step4: There under "Local Users and Groups" Double click on user
Step:5: then right click on postgres and you can set password
refer this below image

Terminal mysql -v gives Access Denied Error 1045 (28000)

When I try to check the mysql version using terminal I get the following error.
KillBill:~ KillBill$ mysql -v
ERROR 1045 (28000): Access denied for user 'KillBill'#'localhost' (using password: NO)
but when I do the following and add the password it works and logs me into MYSQL prompt.
KillBill:~ KillBill$ mysql -u root -p
Why am I getting the following error on mysql -v prompt only. What do I do to fix it? Everything else is working fine, I can connect to mysql db in the apps I am developing no problem whatsoever.
Any help will be highly appreciated. Thank you!
If you start the mysql client without givinng the -u option, it assumes you want to login with the current username, in your case KillBill. If this user isn't a mysql user or is a mysql user, but has to specify a password to login, the user will be refused a connection.
Login as "root", create a mysql user names "KillBill" and assign a password. Have look here for the syntax of that. Then assign appropriate rights using the GRANT statement.

Resources