简体   繁体   中英

How to connect database MySQL in R with Password?

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.

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"

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