I installed mariaDB on digital ocean. I set up user name and password. Now, I am trying to connect it through R studio. But, it is not working.
Code I used.
library(odbc)
library("RMariaDB")
con <- dbConnect(odbc(),
Driver = "MariaDB ODBC 3.1 Driver",
Server = "206.189.---.", #droplet IP
Database = "test",
Username = "root",
Password = " ****"
Trusted_Connection = "True")
Error I got :
Error: nanodbc/nanodbc.cpp:983: HY000: [ma-3.1.7]Can't connect to MySQL server on '206.189.---.--' (10061)
I installed a connection driver on my windows before running these codes on R Studio. What am I missing here?
Related
I am just learning how to use R to connect to SQL database. When I run my code, I am getting a message box says:
library(odbc)
con <- dbConnect(odbc(),Driver = "ODBC Driver 17 for SQL Serve",
Server ="DESKTOP-SHXXX",
Database ="BikeStores",
UID="robin",
PWD = rstudioapi::askForPassword("xxx"),
Trusted_Connection ="yes")
# Error: nanodbc/nanodbc.cpp:1021: 08001: [Microsoft][ODBC Driver 17 for SQL
# Server]Named Pipes Provider: Could not open a connection to SQL Server [2].
# [Microsoft][ODBC Driver 17 for SQL Server]Login timeout expired
# [Microsoft][ODBC Driver 17 for SQL Server]A network-related or instance-
# specific error has occurred while establishing a connection to SQL Server.
# Server is not found or not accessible. Check if instance name is correct
# and if SQL Server is configured to allow remote connections. For more
# information see SQL Server Books Online.
Any help?
I want to connect my Airflow and Microsoft SQL Server. I configured my connection under 'connections' bar in 'Admin' box as mentioned in the following link:
http://airflow.apache.org/howto/manage-connections.html
But when I run my Dag task that is related to SQL server immedatly fails by following error:
[2019-03-28 16:16:07,439] {models.py:1788} ERROR - (18456, "Login failed for user 'XXXX'.DB-Lib error message 20018, severity 14:\nGeneral SQL Server error: Check messages from the SQL Server\nDB-Lib error message 20002, severity 9:\nAdaptive Server connection failed (***.***.***.28:1433)\n")
My code from DAG for Micrososft Sql Connection is following:
sql_command = """
select * from [sys].[tables]
"""
t3 = MsSqlOperator( task_id = 'run_test_proc',
mssql_conn_id = 'FIConnection',
sql = sql_command,
dag = dag)
I verified ip address and port number kind of configuration things by establishing connection through pymssql library from my local computer. Test code is following:
pymssql.connect(server="***.***.***.28:1433",
user="XXXX",
password="XXXXXX"
) as conn:
df = pd.read_sql("SELECT * FROM [sys].[tables]", conn)
print(df)
Could you please share if you have experienced this issue?
By the way I am using VirtualBox in Ubuntu 16.04 LTS
I had the same problem because freetds-dev was missing on linux:
apt-get install freetds-dev
I have created an application in VB. I have successfully connected the application to wamp localhost (same computer). But I can't connect it from another computer that is in the same network. Please help me to connect...
here is my code:
Dim server1 As String
Dim client1 As String
Dim cmd As New Odbc.OdbcCommand
server1 = "Driver={MySQL ODBC 5.1 Driver};Server=localhost;Database=db_checkvoucher;User=root;Password=;Option=3;"
client1 = "Driver={MySQL ODBC 5.1 Driver};server=192.168.1.2;" _
& "User=root;Password=;" _
& "database=db_checkvoucher;"
If Form1.TextBox1.Text = "1" Then
con.ConnectionString = client1
Else
con.ConnectionString = server1
End If
cmd.Connection = New Odbc.OdbcConnection(con.ConnectionString)
con.Open()
I am getting this error:
ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.2' (10060) ERROR [HY000] [MySQL][ODBC 5.1 Driver]Can't connect to MySQL server on '192.168.1.2' (10060)
I have already run wamp server on the server computer.
It's probably an issue with your firewall on the server.
See here for notes on how to allow mysql connections. http://portforward.com/english/routers/firewalling/Microsoft/WindowsXPFirewallFirewall/MySQL_Server.htm
I'm trying to access a PostgreSQL database through R.
I tried the following code:
library(RPostgreSQL)
library(DBI)
drv <- dbDriver("PostgreSQL")
con = dbConnect(drv, #constructs SQL driver
host = MyHost,
port = MyPort,
dbname = MyDbname,
user = MyUser,
password = pw)
I already have PostgreSQL installed on my computer.
With all my credentials being correct, I still get this Error:
Error in postgresqlNewConnection(drv, ...) :
RS-DBI driver: (could not connect [MyUser]#[MyHost] on MyDbname
any ideas what causes the problem? The same problem here has no solution yet. Thanks for your help
> sessionInfo()
R version 3.3.1 (2016-06-21)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.11.6 (El Capitan)
Kasia
At the end, I managed to connect to the database with RPosgres package
install.packages("devtools") and load them
devtools::install_github("RcppCore/Rcpp")
devtools::install_github("rstats-db/DBI")
devtools::install_github("rstats-db/RPostgres")
con <- dbConnect(RPostgres::Postgres(),
host = MyHost,
port = MyPort,
dbname = MyDbname,
user = MyUser,
password = pw)
res <- dbSendQuery(con, "SELECT * FROM orders LIMIT 10")
dbFetch(res)
dbClearResult(res)
I am attempting to create a login mechanism by which you can access a remote SQL Server 2008 R2 database, in a private network, if the credentials are correct. I intend to implement the database at my work server and this program at a client which is in the same subnet as the server. Here is my code so far:
Func Login()
$loginGUI = GUICreate("Login", 250, 150, -1, -1) ; will create a dialog box that when displayed is centered
GUISetState(#SW_SHOW)
GUICtrlCreateLabel ( "Input valid credentials to login", 40, 10,-1,-1)
GUICtrlCreateLabel ( "Username", 40, 40,-1,-1)
Local $userInput = GUICtrlCreateInput("", 100, 37, 100, 20)
GUICtrlSetState($userInput, $GUI_FOCUS)
GUICtrlCreateLabel ( "Password", 40, 70,-1,-1)
Local $passwordInput = GUICtrlCreateInput("", 100, 67, 100, 20, $ES_PASSWORD)
Local $loginButton = GUICtrlCreateButton("Login", 40, 105, 70)
Local $exitButton = GUICtrlCreateButton("Exit", 130, 105, 70)
GUISetState()
; Run the GUI until the dialog is closed
While 1
$msg = GUIGetMsg(1)
Switch $msg[0]
Case $loginButton
$user = GUICtrlRead($userInput)
$password = GUICtrlRead($passwordInput)
Global $loginCon = ObjCreate( "ADODB.Connection" )
With $loginCon
.ConnectionString =("DRIVER={SQL Server};SERVER=192.168.1.30\SQLEXPRESS;DATABASE=Test;UID="&$user&";PWD="&$password&";")
.Open
EndWith
If ($user ="" and $password="") or #error Then
MsgBox(48, "Login error", "Connection failed! Wrong Username/Password.")
GUICtrlSetData($userInput, "")
GUICtrlSetData($passwordInput, "")
GUICtrlSetState($userInput, $GUI_FOCUS)
Else
$loginCon.Close
GUIDelete()
Main()
ExitLoop
EndIf
Case $exitButton
GUIDelete()
ExitLoop
Case $GUI_EVENT_CLOSE
GUIDelete()
ExitLoop
EndSwitch
WEnd
EndFunc
I've also did the following actions:
Used SQL Server Management Studio to allow remote connections as well as the proper permissions for the correct user to access the database.
Used SQL Server Configuration Manager to enable SQL Server Browser and the TCP/IP protocol with the proper configurations to access the server.
Created a firewall Inbound and Outbound rule which allows access to TCP port 1433 and UDP port 1434 for the server and client (just in case).
Added sqlservr.exe and sqlbrowser.exe to the firewall allowed programs list.
Installed SQL Server Native Client 2008 R2 on the client PC.
I could connect locally to my database using the server IP but I get the following error when attempting to connect from the remote client to the server:
err.description is: [Microsoft][ODBC SQL Server Driver][DBNETLIB]SQL Server does not exist or access denied.
Strangely enough, I could connect from the remote client using sqlcmd. I also have to mention that I am currently using my laptop to hold my test database. It's IP is assigned by the DCHP server from work and always remains the same.
Is my code incorrect or do I have to make additional server/client configurations?
Instead of doing that way I suggest to have client and server written in autoit. Put server to remote computer and make it interact with database locally. Than return what you want to client. This approach is more secure also. Here is where you can start