alcina
June 26, 2013, 12:14am
1
Hello all, I am looking for a little insight on how to by pass this
error when running my sctipt… any help is greatly appreciated.
mysqldump: Got error: 1044: Access denied for user ‘root’@‘localhost’ to
database ‘information_schema’ when using LOCK TABLES
tempDir = “/mnt/dumpspace”
dumpUser = “”
dumpUserPass = “”
if Dir["#{tempDir}/"] != nil
puts “exits”
FileUtils.rm_rf(Dir.glob("/mnt/dumpspace/ "))
else
puts “doesn’t exist, this should never be true!”
end
date = Time.now.strftime("%m%e%g")
puts date
db = Mysql.real_connect(‘localhost’,dumpUser,dumpUserPass)
puts “Server version: " + db.get_server_info
db.query(‘show databases’).each do |db|
puts " Dumping - " + db[0] + “\n”
Dir.mkdir(”#{tempDir}/#{db[0]}")
dump = “mysqldump -u #{dumpUser} -p#{dumpUserPass} #{db[0]} >
#{tempDir}/#{db[0]}_#{date}.sql”
exec dump
end
db.close
bowers
June 26, 2013, 1:47am
2
Silly question, but does the user ‘root’@‘localhost’ have LOCK TABLES
in their granted permissions?
bowers
June 26, 2013, 1:50am
3
On 26/06/13 11:46, Matthew K. wrote:
end
db.close
–
Posted via http://www.ruby-forum.com/ .
Aside from the sql permissions, I’m not sure you’ll have much luck
exec’ing in a loop =]
Sam
bowers
June 26, 2013, 3:32am
5
Micah S. [email protected] wrote:
mysqldump: Got error: 1044: Access denied for user ‘root’@‘localhost’ to
database ‘information_schema’ when using LOCK TABLES
Read the mysqldump man page:
mysqldump does not dump the INFORMATION_SCHEMA database by
default. mysqldump dumps
INFORMATION_SCHEMA only if you name it explicitly on the command
line, although currently you must
also use the --skip-lock-tables option. Before MySQL 5.5
mysqldump silently ignores
INFORMATION_SCHEMA even if you name it explicitly on the command
line.
tempDir = “/mnt/dumpspace”
dumpUser = “”
dumpUserPass = “”
if Dir[“#{tempDir}/*”] != nil
puts “exits”
Typo? “exists” ?
puts " Dumping - " + db[0] + “\n”
Dir.mkdir(“#{tempDir}/#{db[0]}”)
dump = “mysqldump -u #{dumpUser} -p#{dumpUserPass} #{db[0]} >
#{tempDir}/#{db[0]}_#{date}.sql”
exec dump
exec
will replace your running script and not return to it.
What you want here, is either backticks, system, or all the way to
something like Open3.capture2 or 3.
end
db.close
If you want a much more elegant solution to this and other backup
things, do look at the Backup gem:
Even if you don’t use it, read it and learn from it. It’s quite an
elegant bit of ruby code.