luarocks错误 require ‘luasql.mysql' 报module 'luasql.mysql' not found:

Posted 苍洱

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了luarocks错误 require ‘luasql.mysql' 报module 'luasql.mysql' not found:相关的知识,希望对你有一定的参考价值。

错误:

require ‘luasql.mysql
stdin:1: module ‘luasql.mysql‘ not found:
no field package.preload[‘luasql.mysql‘]
no file ‘/usr/local/share/lua/5.3/luasql/mysql.lua‘
no file ‘/usr/local/share/lua/5.3/luasql/mysql/init.lua‘
no file ‘/usr/local/lib/lua/5.3/luasql/mysql.lua‘
no file ‘/usr/local/lib/lua/5.3/luasql/mysql/init.lua‘
no file ‘./luasql/mysql.lua‘
no file ‘./luasql/mysql/init.lua‘
no file ‘/usr/local/lib/lua/5.3/luasql/mysql.so‘
no file ‘/usr/local/lib/lua/5.3/loadall.so‘
no file ‘./luasql/mysql.so‘
no file ‘/usr/local/lib/lua/5.3/luasql.so‘
no file ‘/usr/local/lib/lua/5.3/loadall.so‘
no file ‘./luasql.so‘
stack traceback:
[C]: in function ‘require‘
stdin:1: in main chunk
[C]: in ?

环境: ubuntu 已安装lua,未安装mysql

解决方案

一、先安装mysql

Ubuntu上安装MySQL非常简单只需要几条命令就可以完成。

1. sudo apt-get install mysql-server

2. apt-get isntall mysql-client

3.  sudo apt-get install libmysqlclient-dev

参考链接

http://www.linuxidc.com/Linux/2016-07/133128.htm

二 安装luasql-mysql

luarocks install luasql-mysql

参考链接 http://www.runoob.com/lua/lua-database-access.html

三 安装luasql-mysql 出错

Error: Could not find header file for MYSQL
No file mysql.h in /usr/local/mysql
You may have to install MYSQL in your system and/or pass MYSQL_DIR or MYSQL_INCDIR to the luarocks command.
Example: luarocks install luasql-mysql MYSQL_DIR=/usr/local

解决方法:

在终端执行whereis mysql 找到mysql 的include路径

luarocks install luasql-mysql MYSQL_INCDIR=/usr/include/mysql 

注释:配置自己查到的mysql.h 所在路径

 






















以上是关于luarocks错误 require ‘luasql.mysql' 报module 'luasql.mysql' not found:的主要内容,如果未能解决你的问题,请参考以下文章

如何导入 luarocks 本地模块

Windows Luarocks 安装权限错误

Luarocks 上传 - “错误:找不到文件”

命令“luarocks config”给出错误

在 cqueues rock 的 luarocks/gcc 构建中选择了错误的 lib 目录

LuaRocks 找不到 luarocks.lua