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.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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