0

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.

1

2 Answers 2

1
#!/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.

Sign up to request clarification or add additional context in comments.

9 Comments

Still it doesn't work. Can you please elaborate EOF.
EOF is just a tag for shell's here documents. Execute the above shell script, what's your output?@Vivek Sadh
I think I should also specify username and password to log in. Right ? I do mysql -u root -proot << EOF and get nothing as output.
If everything was okay with your SET command there‘s no output.
Thanks. Multiple of 1024 works. See my answer. I tried using a different command.
|
0

Thanks. I figured it out:

mysql -u root -proot -Bse "SET GLOBAL max_allowed_packet=509715456"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.