I am working on mysql. I am trying to acess the mysql database using the Luasql.I have installed Luasql using yum. Then i tried the following code:
mysql = require "luasql.mysql"
env = assert(mysql.mysql())
con = assert(env:connect ( "db_name", "username", "password", "localhost"))
for no, name in rows (con, "select * from t1") do
print (string.format ("%s", name))
end
While executing the above code i am getting the following error :
lua: check.lua:3: LuaSQL: error connecting to database. MySQL: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
stack traceback:
[C]: in function 'assert'
check.lua:3: in main chunk
[C]: ?
How to overcome this error.Can anyone help me for the proper execution of the code? Thanks !!!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…