Reputation: 4268
I want to login to mysql console and set the max packet variable and then exit from the mysql console. I have written the following:
mysql -u root -proot
SET GLOBAL max_allowed_packet=509715201
exit
it only login to mysql and doesn't do anything else.
Upvotes: 0
Views: 280
Reputation: 4268
Thanks. I figured it out:
mysql -u root -proot -Bse "SET GLOBAL max_allowed_packet=509715456"
Upvotes: 0
Reputation: 681
#!/bin/bash
mysql << EOF
SET GLOBAL max_allowed_packet=509715201;
quit
EOF
You should use shell's here documents
to execute sql statement.
Quote from Advanced Bash-Scripting Guide:
A here document is a special-purpose code block. It uses a form of I/O redirection to feed a command list to an interactive program or a command, such as ftp, cat, or the ex text editor.
Upvotes: 1