gpt4 book ai didi

mysql - 安装 db-mysql

转载 作者:行者123 更新时间:2023-11-29 14:39:27 26 4
gpt4 key购买 nike

我刚刚开始接触 Node.js,并希望将 Node.js 与在 MAMP 上运行的现有 PHP/MySQL 堆栈一起使用。

问题:我现有的数据已经存在于以 MAMP 开头的 MySQL 数据库中,并且我想从 node.js 访问它们。我决定使用 db-mysql 驱动程序,因此为了安装它,我通过在终端中输入来指定我的 MYSQL_CONFIG 环境

  1. 导出 MYSQL_CONFIG=/Applications/MAMP/Library/bin/mysql_config
  2. npm 安装 db-mysql

然后出现错误消息:

> db-mysql@0.7.6 install /Users/x/mywebsite/node_modules/db-mysql
> node-waf configure build

Checking for program g++ or c++ : /usr/bin/g++
Checking for program cpp : /usr/bin/cpp
Checking for program ar : /usr/bin/ar
Checking for program ranlib : /usr/bin/ranlib
Checking for g++ : ok
Checking for node path : not found
Checking for node prefix : ok /usr/local
Checking for program mysql_config : /Applications/MAMP/Library/bin/mysql_config
Checking for library mysqlclient_r : Missing libmysqlclient_r
'configure' finished successfully (0.571s)
Waf: Entering directory `/Users/x/mywebsite/node_modules/db-mysql/build'
[ 1/12] cxx: lib/node-db/binding.cc -> build/Release/lib/node-db/binding_1.o
[ 2/12] cxx: lib/node-db/connection.cc -> build/Release/lib/node-db/connection_1.o
[ 3/12] cxx: lib/node-db/events.cc -> build/Release/lib/node-db/events_1.o
[ 4/12] cxx: lib/node-db/exception.cc -> build/Release/lib/node-db/exception_1.o
[ 5/12] cxx: lib/node-db/query.cc -> build/Release/lib/node-db/query_1.o
[ 6/12] cxx: lib/node-db/result.cc -> build/Release/lib/node-db/result_1.o
[ 7/12] cxx: src/connection.cc -> build/Release/src/connection_1.o
In file included from ../src/connection.cc:2:
../src/./connection.h:5:19: error: mysql.h: No such file or directory
In file included from ../src/./connection.h:8,
from ../src/connection.cc:2:
../src/././result.h:16: error: expected ‘,’ or ‘...’ before ‘&’ token
../src/././result.h:16: error: ISO C++ forbids declaration of ‘MYSQL_FIELD’ with no type
../src/././result.h:28: error: expected `)' before ‘*’ token
../src/././result.h:54: error: ISO C++ forbids declaration of ‘MYSQL’ with no type
../src/././result.h:54: error: expected ‘;’ before ‘*’ token
../src/././result.h:55: error: ISO C++ forbids declaration of ‘MYSQL_RES’ with no type
../src/././result.h:55: error: expected ‘;’ before ‘*’ token
In file included from ../src/connection.cc:2:
../src/./connection.h:43: error: ISO C++ forbids declaration of ‘MYSQL’ with no type
../src/./connection.h:43: error: expected ‘;’ before ‘*’ token
../src/connection.cc: In constructor ‘node_db_mysql::Connection::Connection()’:
../src/connection.cc:11: error: class ‘node_db_mysql::Connection’ does not have any field named ‘connection’
../src/connection.cc: In member function ‘virtual bool node_db_mysql::Connection::isAlive(bool)’:
../src/connection.cc:57: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:57: error: ‘mysql_ping’ was not declared in this scope
../src/connection.cc: In member function ‘virtual void node_db_mysql::Connection::open()’:
../src/connection.cc:65: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:65: error: ‘mysql_init’ was not declared in this scope
../src/connection.cc:66: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:71: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:71: error: ‘MYSQL_SET_CHARSET_NAME’ was not declared in this scope
../src/connection.cc:71: error: ‘mysql_options’ was not declared in this scope
../src/connection.cc:75: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:75: error: ‘MYSQL_OPT_COMPRESS’ was not declared in this scope
../src/connection.cc:75: error: ‘mysql_options’ was not declared in this scope
../src/connection.cc:79: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:79: error: ‘MYSQL_INIT_COMMAND’ was not declared in this scope
../src/connection.cc:79: error: ‘mysql_options’ was not declared in this scope
../src/connection.cc:83: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
[ 8/12] cxx: src/mysql.cc -> build/Release/src/mysql_1.o
../src/connection.cc:83: error: ‘MYSQL_OPT_READ_TIMEOUT’ was not declared in this scope
../src/connection.cc:83: error: ‘mysql_options’ was not declared in this scope
../src/connection.cc:90: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:90: error: ‘MYSQL_OPT_SSL_VERIFY_SERVER_CERT’ was not declared in this scope
../src/connection.cc:90: error: ‘mysql_options’ was not declared in this scope
../src/connection.cc:93: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:93: error: ‘MYSQL_OPT_CONNECT_TIMEOUT’ was not declared in this scope
../src/connection.cc:97: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:97: error: ‘MYSQL_OPT_WRITE_TIMEOUT’ was not declared in this scope
../src/connection.cc:101: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:108: error: ‘mysql_real_connect’ was not declared in this scope
../src/connection.cc:116: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:116: error: ‘mysql_error’ was not declared in this scope
../src/connection.cc: In member function ‘virtual void node_db_mysql::Connection::close()’:
../src/connection.cc:122: error: ‘class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:122: error: ‘mysql_close’ was not declared in this scope
../src/connection.cc: In member function ‘virtual std::string node_db_mysql::Connection::escape(const std::string&) const’:
../src/connection.cc:133: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:133: error: ‘mysql_real_escape_string’ was not declared in this scope
../src/connection.cc: In member function ‘virtual std::string node_db_mysql::Connection::version() const’:
../src/connection.cc:141: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:141: error: ‘mysql_get_server_info’ was not declared in this scope
../src/connection.cc: In member function ‘virtual node_db::Result* node_db_mysql::Connection::query(const std::string&) const’:
../src/connection.cc:150: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:150: error: ‘mysql_real_query’ was not declared in this scope
../src/connection.cc:151: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’
../src/connection.cc:151: error: ‘mysql_error’ was not declared in this scope
../src/connection.cc:154: error: ‘const class node_db_mysql::Connection’ has no member named ‘connection’
In file included from ../src/./mysql.h:7,
from ../src/mysql.cc:2:
../src/././connection.h:5:19: error: mysql.h: No such file or directory
In file included from ../src/././connection.h:8,
from ../src/./mysql.h:7,
from ../src/mysql.cc:2:
../src/./././result.h:16: error: expected ‘,’ or ‘...’ before ‘&’ token
../src/./././result.h:16: error: ISO C++ forbids declaration of ‘MYSQL_FIELD’ with no type
../src/./././result.h:28: error: expected `)' before ‘*’ token
../src/./././result.h:54: error: ISO C++ forbids declaration of ‘MYSQL’ with no type
../src/./././result.h:54: error: expected ‘;’ before ‘*’ token
../src/./././result.h:55: error: ISO C++ forbids declaration of ‘MYSQL_RES’ with no type
../src/./././result.h:55: error: expected ‘;’ before ‘*’ token
In file included from ../src/./mysql.h:7,
from ../src/mysql.cc:2:
../src/././connection.h:43: error: ISO C++ forbids declaration of ‘MYSQL’ with no type
../src/././connection.h:43: error: expected ‘;’ before ‘*’ token
Waf: Leaving directory `/Users/x/mywebsite/node_modules/db-mysql/build'
Build failed:
-> task failed (err #1):
{task: cxx connection.cc -> connection_1.o}
-> task failed (err #1):
{task: cxx mysql.cc -> mysql_1.o}
npm ERR! error installing db-mysql@0.7.6 Error: db-mysql@0.7.6 install: `node-waf configure build`
npm ERR! error installing db-mysql@0.7.6 `sh "-c" "node-waf configure build"` failed with 1
npm ERR! error installing db-mysql@0.7.6 at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/exec.js:49:20)
npm ERR! error installing db-mysql@0.7.6 at ChildProcess.emit (events.js:70:17)
npm ERR! error installing db-mysql@0.7.6 at maybeExit (child_process.js:359:16)
npm ERR! error installing db-mysql@0.7.6 at Process.onexit (child_process.js:395:5)

> db-mysql@0.7.6 preuninstall /Users/x/mywebsite/node_modules/db-mysql
> rm -rf build/*

npm ERR! db-mysql@0.7.6 install: `node-waf configure build`
npm ERR! `sh "-c" "node-waf configure build"` failed with 1
npm ERR!
npm ERR! Failed at the db-mysql@0.7.6 install script.
npm ERR! This is most likely a problem with the db-mysql package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-waf configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls db-mysql
npm ERR! There is likely additional logging output above.
npm ERR!
npm ERR! System Darwin 11.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "db-mysql"
npm ERR! cwd /Users/x/mywebsite
npm ERR! node -v v0.6.2
npm ERR! npm -v 1.0.106
npm ERR! code ELIFECYCLE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/x/mywebsite/npm-debug.log
npm not ok

我哪里出错了?或者有更好的方法来设置db-mysql

最佳答案

使用node-mysql效果很好

关于mysql - 安装 db-mysql,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8275482/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com