Access Denied for User ODBC # localhost - windows

i have installed Mysql on Windows7, 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. i also tried to login in cmd with this command
mysql –u root -p mypassword
but still same error. and my password is 100% correct. kindly tell me how to solve this problem. Thanks

Have you tried storing pass in the cfg file? http://dev.mysql.com/doc/refman/5.7/en/password-security-user.html

try from command line:
mysql -u root -p
and then, when you are being asked for password, just type it.
Try the same with mysqldump command without typing your password after -p.

Related

Changing user when running psql command on Mac terminal

I installed PostgreSQL on my Mac (from their website) and set it up to have it run on my terminal using psql command. However, when I use psql command, it asks for password for my Mac user and when I enter the password, it returns password authentication error. I only have postgres set up as a user. When I run psql -U postgres and enter the password, I am connected to the database.
How can I change the default user to postgres instead of my Mac user (jp) so I can just use psql command? I have also included what I have in .bash_profile file.
I also encountered the same problem, but it seems that setting the environment variable export PGUSER = "WUTONK" in the terminal is useless, It still takes my local user name as the default connection user, even in the account where I have not registered this name in the PostgreSQL

How to use PGPASS file in Powershell to avoid password prompt?

I had to automate my postgre database backup. As instructed by my software vendor I am trying to use pg_dump.exe (see below) file to take a backup but that prompts me for password.
.\pg_dump.exe -h localhost -p 4432 -U postgres -v -b -F t -f "C:\Backup\Backup.tar" Repo
So googled and found that as per "https://www.postgresql.org/docs/9.6/libpq-pgpass.html" I can create a pgpass.conf file within 'C:\Users\User1\AppData\Roaming\postgresql\pgpass.conf" which I did.
Then I tried to pass data of pgpass.conf file to env variable before executing my pg_dump command. But it is not working. Still I am getting prompt to enter password. This is the content of pgpass.conf file: *:*:*:postgres:password
Below is the code I am trying in PowerShell,
$Env:PGPASSFILE="C:\Users\User1\AppData\Roaming\postgresql\pgpass.conf"
cd "C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin"
.\pg_dump.exe -h localhost -p 4432 -U postgres -v -b -F t -f "C:\Backup\Backup.tar" Repo
Why am I still being asked for password?
When I type following code $Env:AppData I get following response "C:\Users\User1\AppData\Roaming"
Everywhere there are guidance on how to use it in UNIX or command prompt but not in powershell. Any help is appreciated. Also if you could direct me how to secure this password file then it will be great.
With password prompt I cannot automate it with windows task scheduler.
I suspect you have a suitable solution, however, as a quick (and not secure) workaround via the command prompt, you can use the variable PGPASSWORD to hold the password then run the backup script.
A sample might be something like:
SET PGPASSWORD=password
cd "C:\Program Files\Qlik\Sense\Repository\PostgreSQL\9.6\bin" pg_dump.exe -h localhost -p 4432 -U postgres -b -F t -f "d:\qs_backup\QSR_backup.tar" QSR
Rod
I have yet to get the damned thing to work yet, but I did find this:
-w
--no-password Never issue a password prompt. If the server requires password authentication and a password is not available by other means
such as a .pgpass file, the connection attempt will fail. This option
can be useful in batch jobs and scripts where no user is present to
enter a password.
I don't see a -w parameter in your call to pg_dump
I used pg_hba file to allow connection "trust" this is riskier method but I had to get things done ASAP. Thank you for your time and effort

Postgres easy login with pgpass and alias not working

I am trying to use a one word alias to access a postgres database, the problem I am having is it needs a carriage return to work. Can anyone help me to get it to log in without the carriage return?
This is my alias which is in an environment file I am dotting:
alias pgres='psql --host cloudpoc.test.com.au -p 8367 -U kevin -W kev_db'
This is my .pgpass file which is in the users home directory:
cloudpoc.test.com.au:8367:kev_db:kevin:kevpass123
If I type "pgres" then I get a prompt for a password. I have to hit enter again to log in.
Shouldn't it just log me straight in?
Prompting for a password is what -W is for. If you don't want that behavior, then don't use -W.
You can specify the database connection parameters in a postgresql service file called ~/.pg_service.conf in you home. Based on your connection string:
cloudpoc.test.com.au:8367:kev_db:kevin:kevpass123
You would enter the following in ~/.pg_service.conf:
# Kevin's database service
[kev]
host=cloudpoc.test.com.au
port=8367
user=kevin
dbname=kev_db
password=kevpass123
And you would then connect to the database with:
psql service=kev

Using Mysqldump with root user and blank password

My MySql has a user root and blank password (which is default). I am using windows command line in my local machine. Now I would like to use below command with blank password.
mysqldump -u root magentotwo > magentotwo2.sql;
When I use above command, CMD is asking for password and I press Enter. Then CMD showing error. How can I use that command??

ruby script to enter prompt command from a system command

I'm trying to write a simple script to mysqldump some dbs. I'm getting stuck on the password prompt though.
I'd like to just have a config file that contains all the db creds, then the script can use those to connect to the db.
Problem is a command such as:
system('mysqldump -u username -p')
then prompts for
Enter password:
even when I do something like:
system('mysqldump -u username -p some_password')
I still get prompted for the password...
I don't do a whole lot of scripting in Ruby so I'm at a loss as to how my script can automatically enter this info so the user running the script doesn't have to.
If you already know the password why aren't you passing it to the command?
system('mysqldump -u username --password=mypassword')
you need to delete space after -p
system('mysqldump -uusername -psome_password')
or without password just
system('mysqldump -uusername')
or
system('mysqldump -uusername --password=')
you could always check the application that uses the database for the password, check the config file file for the connection string. Failing that change the password in the database.

Resources