package.path require mysql 报错

在文件中

package.path = ‘/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/lualib/resty/?.lua;‘
package.cpath = ‘/usr/local/lib/lua/5.1/?.so;‘

执行local mysql = require "mysql" --正确local mysql = require "resty.mysql" --报错

去掉
package.path = ‘/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/lualib/resty/?.lua;‘
package.cpath = ‘/usr/local/lib/lua/5.1/?.so;‘
local mysql = require "mysql" --报错local mysql = require "resty.mysql" --正确

package.path 的默认路径指向哪的呢?

去掉 package.path,在页面中 随便引用一个不存在的模块 比如 require ‘aa‘

查看nginx错误日志返回

    no field package.preload[‘aa‘]
    no file ‘/usr/local/openresty/lualib/aa.lua‘
    no file ‘/usr/local/openresty/lualib/aa/init.lua‘
    no file ‘./aa.lua‘
    no file ‘/usr/local/openresty/luajit/share/luajit-2.1.0-alpha/aa.lua‘
    no file ‘/usr/local/share/lua/5.1/aa.lua‘
    no file ‘/usr/local/share/lua/5.1/aa/init.lua‘
    no file ‘/usr/local/openresty/luajit/share/lua/5.1/aa.lua‘
    no file ‘/usr/local/openresty/luajit/share/lua/5.1/aa/init.lua‘
    no file ‘/usr/local/openresty/lualib/aa.so‘
    no file ‘./aa.so‘
    no file ‘/usr/local/lib/lua/5.1/aa.so‘
    no file ‘/usr/local/openresty/luajit/lib/lua/5.1/aa.so‘
    no file ‘/usr/local/lib/lua/5.1/loadall.so‘

发现  /usr/local/openresty/lualib/aa.lua 难道默认的路径是 /usr/local/openresty/lualib 于是在页面中加入

package.path = ‘/usr/local/share/lua/5.1/?.lua;/usr/local/openresty/lualib/resty/?.lua;/usr/local/openresty/lualib/?.lua;‘

package.cpath = ‘/usr/local/lib/lua/5.1/?.so;‘

执行正确

新手~~ 勿怪

时间: 2024-11-03 09:25:16

package.path require mysql 报错的相关文章

mysql报错问题解决Character set 'utf8mb4' is not a compiled character set

mysql: Character set 'utf8mb4' is not a compiled character set and is not specified in the '/usr/share/mysql/charsets/Index.xml' file 报错的解决方法 1.由于日常程序使用了字符集utf8mb4,为了避免每次更新时,set names utf8mb4,就把配置文件改了,如下: 增加了mysql客户端的默认字符集设置 [[email protected]~]# vim

解决mysql报错Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’

启动mysql 报错: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) 1.先查看 /etc/rc.d/init.d/mysqld status 看看m y s q l 是否已经启动.另外看看是不是权限问题. 2.确定你的mysql.sock是不是在那个位置,mysql -u 你的mysql用户名 -p -S /var/lib/mysql/

MySQL报错“1366 - Incorrect integer value: '' XXXXXXX' at row 1 ”

出现这个错误是因为我在表中插入了一条含有中文字符的语句: 修改方法: my.ini中查找sql-mode 将 sql-mode="STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION", 修改为 sql-mode="NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION", 重启mysql后即可 . MySQL报错"1366 - Incorrect int

mysql报错:MySQL server version for the right syntax to use near 'type=InnoDB'

工作中使用sql语句建表时,mysql报了如下错误: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'type=InnoDB' at line 1 解决方案: 这个报错是由于某些版本的mysql不支持type写法,将type关键词改成ENGINE 即可. 版权声明:本文为博主原

连接mysql报错:error 2003 (hy000):can't connect to mysql server on 'localhost' (10061)

一.mysql 的bin目录下有个MySQLInstanceConfig.exe,运行就可以进行创建数据库实例,创建实例时也可以生成windows 服务,把服务设置成自动启动就可以了 二.安装在D盘的discuzz!打开后出现上述错误,请问应如何处理?winmysqladmin已经启动,但三色树上有一个小红点如果出现"ERROR 2003: Can't connect to MySQL server on 'localhost' (10061)",说明你的MySQL还没有启动.解决办法

Linux系统下启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with

Linux系统下启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with 摘要 Linux系统下安装完MySQL,启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with... Linux系统下装完MySQL,然后重启动时报错: 解决方法:  查看cat /etc/h

Mysql报错Forcing close of thread 139 user: 'root'

最近重启服务器的mysql总是报大量的如下错误: 160330  9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 139  user: 'root' 160330  9:14:26 [Warning] /usr/libexec/mysqld: Forcing close of thread 138  user: 'root' 160330  9:14:26 [Warning] /usr/libexec/mysqld: 

Linux系统下启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with

Linux系统下启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with 摘要 Linux系统下安装完MySQL,启动MySQL报错:Neither host 'localhost.localdomain' nor 'localhost' could be looked up with... Linux系统下装完MySQL,然后重新启动动时报错: 解决方法:  查看cat /etc

一看便知linux下mysql报错ERROR 1044: Access denied for user: '@localhost' to database 'mysql'

错误信息:ERROR 1044: Access denied for user: '@localhost' to database 'mysql' linux下解决方案: mysql> use mysql ERROR 1044 (42000): Access denied for user 'root'@'localhost' to database 'mysql' mysql> exit Bye [[email protected] ~]# service mysqld stop如果该命令不