0

My problem is that I am able connect database without using password and also able execute the queries but when I am trying to connect database with password it is giving error. The details I have mentioned below what I am doing and what is the error:

>library(DBI)
>library(RMySQL)
>drv<-dbDriver("MySQL")
>con<-dbConnect(drv,user="sam",password="sam123",dbname="test")

then the error is like:

Error in mysqlNewConnection(drv, ...) : 
  RS-DBI driver: (Failed to connect to database: 
  Error: Access denied for user 'sam'@'localhost' (using password: YES)

Please help me out of this problem.

rcs
  • 67,191
  • 22
  • 172
  • 153
Saurabh
  • 867
  • 3
  • 13
  • 28

1 Answers1

0

It seems permission issue for usr "sam" in your database.

You should check mysql.users table and provide necessary permissions, if you are trying to access from remote server, you should add IP address of remote server in users table with username ="sam"

Minesh
  • 2,284
  • 1
  • 14
  • 22
  • I am able to sole the issue and the process that I have done is like that:sudo service mysql stop sudo mysqld --skip-grant-tables ****** In another terminal, start the mysql client and select the mysql database. If the root user entries are still there, just set a password using query " update user set password=password('sam123') where user='sam';" Then its working fine for me. – Saurabh Jan 31 '13 at 13:02
  • @user1985919: It is unclear from the comment whether you have success. If you do, then mark the question as "answered". – IRTFM Jan 31 '13 at 13:58
  • I have solved the issues by the above said method so I am making remark as answered – Saurabh Feb 01 '13 at 05:21
  • @user1985919 actually you need to click on Tick mark on left top of this answer and if you like click on up arrow button to give up vote. thanks :) – Minesh Feb 01 '13 at 05:24