BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
leonzheng
Obsidian | Level 7

I am trying to upload data into an existing table in mysql database, using append. I am able to pull data from that table which means connection should be OK. Here is my code for data pulling with database information:

proc sql;

connect to mysql (server="thisistheserver.com" port=3311

   user="username" password="mypassword");

create table want as select * from connection to mysql

(

  select *

from databaseschema.existingdata

);

disconnect from mysql;

quit;

 

Now below is my code to append:

libname DB mysql dsn = "thisistheserver.com" schema=databaseschema port = 3311 uid = "username" password = "mypassword";
proc append base = DB.existingdata data = have force;
run;

 

It returns error: error trying to establish connection: can't connect to local mysql server through socket
'/var/lib/mysql/mysql.sock' (2)

error: error in the libname statement.

error: libref DB is not assigned.

 

Please help me on this,

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
r_behata
Barite | Level 11

Check you Libname Statement, The SAS/Access Libname to Mysql should be like :

 

libname mysqllib mysql user=username password=mypassword database=databaseschema  server=thisistheserver.com port=3311;

View solution in original post

2 REPLIES 2
r_behata
Barite | Level 11

Check you Libname Statement, The SAS/Access Libname to Mysql should be like :

 

libname mysqllib mysql user=username password=mypassword database=databaseschema  server=thisistheserver.com port=3311;
leonzheng
Obsidian | Level 7

Thanks, now it seems libref is assigned and connection is established.

However, there is a new error in

proc append base = DB.existingdata data = have force;
run;

error: no database selected SQL statement: SELECT * FROM 'existingdata'. 

 

I used append locally before and there was never such an error be seen.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1024 views
  • 0 likes
  • 2 in conversation