OpenVZ Forum


Home » General » Support » Cannot use msql -e "<some sql commands>" with vzctl exec
Cannot use msql -e "<some sql commands>" with vzctl exec [message #50706] Wed, 16 October 2013 11:00 Go to next message
proxmoxUser is currently offline  proxmoxUser
Messages: 2
Registered: September 2013
Junior Member
Hello everyone,

I am managing 2 proxmox host nodes with about 50 containers running on both, each one of it running Mysql. In order to use it in a script, i would need to list databases names of each containers' mysql.

To do that, i tried to use :
#Firstly
vzctl exec 152 mysql -u root --password=xxxxxxxx -e "SHOW DATABASES;"
ERROR 1049 (42000): Unknown database 'DATABASES'

#and then
root@myserver:# vzctl exec 152 /bin/bash --login -c "mysql -u root --password=xxxxxxxxxx -e 'SHOW DATABASES;'"
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)


even though :
root@myserver# vzctl enter 152
entered into CT 152
root@CT152:/# mysql -u root --password=xxxxxxxx -e "SHOW DATABASES;"
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| mybdd1             |
| mybdd2             |
+--------------------+


I don't know if this is a bug, or this is a normal behavior of the system, but if it is not a bug, I could really not guess why this is happening.

So does someone knows if doing this is possible ? If so could you tell me how I can ?

Anyway does also someone can explain this behavior of vzctl to me ?

It would be great !
If this is not a normal thing happening on my server, I will post an issue on BugZilla, but I don't want to spam the platform.

Thank you very much in advance !

Rémi
Re: Cannot use msql -e "<some sql commands>" with vzctl exec [message #50727 is a reply to message #50706] Sun, 20 October 2013 06:21 Go to previous messageGo to next message
dipps is currently offline  dipps
Messages: 22
Registered: May 2013
Location: Out in the scrub
Junior Member
The first one works for me if you put quotes around the whole mysql command:

vzctl exec NNN 'mysql -u root --password=XXXXXX -e "show databases;"'
Re: Cannot use msql -e "<some sql commands>" with vzctl exec [message #50732 is a reply to message #50727] Tue, 22 October 2013 03:15 Go to previous messageGo to next message
devonblzx is currently offline  devonblzx
Messages: 127
Registered: December 2006
Senior Member
That or you could try escaping inner quotes with:

vzctl exec NNN "mysql -e \"SHOW DATABASES\""



http://static.openvz.org/userbars/openvz-user-2.png
ByteOnSite President
Re: Cannot use msql -e "<some sql commands>" with vzctl exec [message #50735 is a reply to message #50732] Tue, 22 October 2013 08:12 Go to previous message
proxmoxUser is currently offline  proxmoxUser
Messages: 2
Registered: September 2013
Junior Member
Hello !

Thank you, it was it !
I didnt't even try to put quotes because nothing is mentionned about it in the doc/man, and basic commands (such as ls, cat, etc.) work fine without.
I will know that now !

So, issue resolved Smile

Have a good day !

Rémi

ps : I'm not sure but I think there isn't a "solved" option for OP in this forum, or I didn't find it. If I am wrong, please tell me and I will change the status !
Previous Topic: What are recommended Disk settings for a DB server?
Next Topic: Debian 7 (wheezy) in a 32-bit hardware node
Goto Forum:
  


Current Time: Sat Nov 09 05:02:50 GMT 2024

Total time taken to generate the page: 0.04513 seconds