I can't set a new variable on mysql - mysql

I want to increase max_allowed_packet variable on my server and I don't know why, when I add the sentence in /etc/my.cnf, it doesn't work!! This is the line I added:
max_allowed_packet=62M
But when I check the current value through mysqladmin variables, it shows 10M!! I've even restarted my server! And nothing happens!
What happens here?

The settings file will normally have several sections (what MySQL calls groups). You're possibly disregarding that fact:
# The following options will be passed to all MySQL clients
[client]
port = 3306
socket = /tmp/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 384M
max_allowed_packet = 1M

Related

Could not start the Mysql service on Local Computer "Error 3: The system cannot find the path specified"

I'm trying to install "MYSQL -5.5.62-win32" on windows XP manually.
The existing MYSQL is MySQL 4.1.22-community-nt. It works like a breeze!
I have done the following:-
Stopped mysql server
my.ini
Renamed "my.ini" on c:/windows =>"my_old.ini"
Copied "my-medium.ini" from "mysql-5.5.62-win32" folder to c:/windows
Renamed "my-medium.ini" => "my.ini" on c:/windows
mysql folder
Renamed "mysql" folder on c:/ =>"mysql_old"
Copied "mysql-5.5.62-win32" to c:/
Renamed "mysql-5.5.62-win32" =>"mysql"
Now, when I try to restart the mysql server, the following error message is displayed:
Could not start the Mysql service on Local Computer
Error 3: The system cannot find the path specified
Please note:-
Unlike the previous "my.ini" file, the new "my.ini" file doesn't include any reference to the location of the "MYSQL" server.
This is the content of old "my.ini"
[mysqld]
basedir = C:/mysql/
datadir = C:/public_html/db/
[WinMySQLadmin]
Server=C:/mysql/bin/mysqld-nt.exe
user=[username]
password=password]
This is the content of the new "my.ini"
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock
# The MySQL server
[mysqld]
port = 3306
socket = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
Please note that I couldn't find "mysql.sock" anywhere on the desktop. I am told that there is no need for the line:-
socket = /tmp/mysql.sock
MYSQL worked without it.
Please help!
Bill's suggestion,"MySQL 5.5", would have been OK, but it needed a lot of work.
In the end, I tried "mysql-5.0.20-win32". It does the job and everyone is happy now.

MySQL Remote Connection Issues

I've just learnt the basics of MySQL to allow me to upload tables onto my Wordpress site through wpdatatables. However, I can't for the life of me work out how to get a remote access connection working. There is plenty of literature and forum posts out there to help with this and I've tried a number of way but I haven't had any success.
I've created privileges for a user called morts81 using the code below:
GRANT ALL PRIVILEGES ON *.* TO 'morts81'#'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Then I've opened up the my.cnf file to ensure that the bind.address line is removed, however, I don't have a bind.address line so I imagine that isn't an issue.
# The MySQL server
[mysqld]
user = mysql
port=3306
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
skip-external-locking
key_buffer = 16M
max_allowed_packet = 1M
table_open_cache = 64
sort_buffer_size = 512K
net_buffer_length = 8K
read_buffer_size = 256K
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 8M
Then finally I try and check the connection from inside the wpdatatable plug-in for Wordpress and I get the following error:
I've also tried replacing localhost in the wpdatatables input with 127.0.0.1 which seems to be recommended on some forums but I get a separate error then:
Would appreciate any help on what I'm doing wrong here.
The socket you specified is different in your config file to start the mysql server. If you can connect to the socket as shown in first error message, use the below socket configuration
socket = /Applications/XAMPP/xamppfiles/var/mysql/mysql.sock
For the 2nd error, see if your mysql server is accessible from the server/service datatables is running on.

Packet for query is too large MySQL

I have a tomcat app connecting to a MySQL Db / java application
I keep getting
Packet for query is too large 1080>1024
I tried changing my.cnf:
in my.cnf the Max packet size is defined as 50 MB and
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
lower_case_table_names = 1
skip-external-locking
bind-address = 0.0.0.0
key_buffer = 16M
max_allowed_packet = 50M
thread_stack = 192K
thread_cache_size = 8
group_concat_max_len=100000
innodb_lock_wait_timeout=300
innodb_buffer_pool_size=22G
innodb_locks_unsafe_for_binlog = ON
innodb_additional_mem_pool_size=40M
I have even tried passing the Param as part of the connection string
jdbc:mysql://serverIP:3306/dbname?maxAllowedPacket=2048000
to the jdbc driver - still I keep getting
Packet for query is too large 1080>1024
This keeps coming every few hours.
What should I check?
MySQL version is 5.5
Thanks for the help.
For those who just want to temparery increase the size of max_allowed_packet and don't want to make this change permanent, try execute sql:
use your_db;
set global max_allowed_packet = 1024*1024*10; # set size to 10M
to verify whether it takes effect or not, you need to open a new query session and execute:
show VARIABLES like '%max_allowed_packet%';
Please note this change is temparery and will restore to default when mysql restart.
It looks like something isn't configured right... Did you restart MySQL after making the config changes? You have to configure the size on both ends:
Both the client and the server have their own max_allowed_packet variable, so if you want to handle big packets, you must increase this variable both in the client and in the server.
However, the server's default size is 1mb (1024 kb). Given your error says 1080>1024 I'm guessing your configuration changes didn't take place (at least not on both client and server).
This happens because either a query, row or a binary log event are greater than 1mb:
A communication packet is a single SQL statement sent to the MySQL server, a single row that is sent to the client, or a binary log event sent from a master replication server to a slave.
I'd try bumping to 5mb on the client and the server (including your replication instance if you have one). You'll have to bounce MySQL for changes to take effect.
https://dev.mysql.com/doc/refman/5.5/en/packet-too-large.html

MySQL missing key_buffer_size in my.cnf

I have never really played around with mysql settings before, but on our new linux cloud server it appears that mysql is eating up all the memory till it crashes, then it cannot restart as there is no more memory to restart the service, I have to reboot the cloud server.
So I was looking at how I could tame the memory usage, and after reading about key_buffer_size (and another setting I cannot recall of the my head) I had a look at the my.cnf file, and there is nothing with this setting on it. My my.cnf is as follows...
[client]
port = 3306
socket = /var/run/mysqld/mysqld.sock
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
[mysqld]
user = mysql
pid-file = /var/run/mysqld/mysql.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
datadir = /var/lib/mysql
[mysql]
!includedir /etc/mysql/conf.d
Without the key_buffer_size set... will it just keep eating up memory till it runs out? Shouldn't this setting be set?
Cheers
The default for key_buffer_size is 8M per http://dev.mysql.com/doc/refman/5.0/en/server-parameters.html
However, I would ask that you set these first (and restart MySQL) and see if the problem persists.
key_buffer = 16M
max_allowed_packet = 16M
thread_stack = 192K
thread_cache_size = 8
query_cache_limit = 1M
query_cache_size = 16M
If after those settings are used, the problem persists, then it's likely not a configuration issue, but something deeper.
Additionally, see these:
https://dba.stackexchange.com/questions/31182/mysql-slowly-uses-memory-until-it-starts-to-use-swap
https://dba.stackexchange.com/questions/7400/why-does-mysql-use-all-of-memory-and-goes-into-swap-when-doing-lots-of-delayed-i
Thanks kinds for the advice!
Turns out it was the innodb_buffer_pool_size. It was set to high for my machine. I have adjusted it as well as optimized how much memory Apache uses. Everything seems to be running better and there is a bit of memory headroom. Hope that fixes it.

Is there a maximum limit for the value max_allowed_packet?

I am running a drupal site. I got an error in my site user warning: Got a packet bigger than 'max_allowed_packet' bytes query. I have set the value as high as 128M . Even after that same error is reported.
What is the issue here?? Why is it not working ??
Is there a maximum limit for the value max_allowed_packet ?
This is the bleeding edge:
set global max_allowed_packet=1073741824;
Although, it is probably not a good idea to set it that high in your case.
As a side note, I experienced this error with mysqldump, and setting this maximum didn't help. This did the trick: $ mysqldump --max_allowed_packet=999M -u root -p table_name > table_name.sql
Often this can be caused by the variables not actually taking effect- you make the configuration change, but in the wrong my.cnf, or you forget to bounce the app, etc.
An easy way to check a running mysql instance is to do something like this in a shell:
mysqladmin variables -u root -p
and enter in your root password. This will dump all of the current variables (including max_allowed_packet), and will let you verify what it's set to. If it's set to 128M and you're still choking on it, then you'll need to increase it- but it's pretty unlikely.
first is you need to set your max_allowed_packet to 128M in your my.cnf file.
to find it, use "locate my.cnf" command in your command line.
the file should look like this:
#
!includedir /etc/my.cnf.d
#max_allowed_packet = 1024M
[mysqld]
port = 3306
key_buffer_size = 256M
# max_allowed_packet = 100M
table_open_cache = 256
sort_buffer_size = 1M
read_buffer_size = 1M
read_rnd_buffer_size = 4M
myisam_sort_buffer_size = 64M
thread_cache_size = 8
query_cache_size= 16M
thread_concurrency = 8
bind-address = 202.90.158.47
# skip-networking
log = /var/log/mysql.access.log
log-error = /var/log/mysql.error.log
wait_timeout = 1
[mysqldump]
#max_allowed_packet = 101M
be sure to uncomment(remove the # sign before the max_allowed_packet = 128M line)
and finally, restart your sql using command "/etc/init.d/mysqld restart"
that should do the trick. :D
Edit your /etc/my.cnf, adding the max_allowed_packet variable.
It should look like this:
[mysqld]
max_allowed_packet=1000000000
Then restart your server.
Try setting max_allowed_packet = 128M as the very last option under the [mysqld] category of my.cnf.
When I had it as the first option, it would not work, but when I had it as the last option, it worked! I think this is because some other variables were over-riding max_allowed_packet.
After changing my.cnf, restart MySQL using sudo service mysql restart, and check the setting using SHOW VARIABLES LIKE 'max_allowed_packet';
You need to set the setting in all sections that apply to the action you are doing, and always in the [MySQLd] section. The setting applies to the buffer of the elements you are using. So under [MySQLd] is for your MySQL server proces deamon on linux / service on windows. And if you want to make a dump with MySQLDump add it as parameter on the command line or make a section [MySQLDump] in your my.ini as well for this tool with the same parameter to make it permanent. If you want to import the dump again with MySQL again use the parameter on the command line or make a section [MySQL] with again the same parameter in your my.ini to make the choice permanent for this tools also.
I kept on talking about my.ini because i am on windows but on linux that is my.cnf of course.
I decided to explain it here because it took me ages to figure this out because it is not explained anywhere. In examples however i noticed some ppl having the setting under multiple sections so i started to google more and found correlation between the sections and the actions they where doing. Now i never have this problem anymore and settings as high as the mentioned 128M here are not needed in most cases. However because it's the maximum the server will use for this buffer if you have the memory just set it high enough to never get into trouble with your actions. The size you actually need is a little bit larger than the largest record in your database.
I experienced this error with mysqldump with LONGBLOB fields, and setting this maximum didn't help. This did the trick:
$ mysqldump --max_allowed_packet=999M -u root -p table_name > table_name.sql