0
#!/usr/local/bin/ruby

require 'mysql'
db=Mysql.new '127.0.0.1','root','123456'
db.create_db 'testdb'   

エラーメッセージ:

test.rb:5:in `<main>': undefined method `create_db' for #<Mysql:0x000000015d0ab0> (NoMethodError)

どうしたの?

4

1 に答える 1

0

Though it is still in the API, create_db cannot be used since mysql4.1.

This function is deprecated. It is preferable to use mysql_query() to issue an SQL CREATE DATABASE statement instead.

Therefore you need to use query as

require 'mysql'
db = Mysql::new('127.0.0.1','root','123456')
db.query("create database testdb;");
db.close
于 2012-10-12T06:59:43.663 に答える