#!/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)
どうしたの?
#!/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)
どうしたの?
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