MySQL command line client crashes - mysql

While I try to source a .sql file of size 6GB, MySQL command line client crashes abruptly without even throwing any error.
I tried to set max_allowed_packet to a limit of 16M and tried SET ##local.net_read_timeout=360;.
The SQL file does not have any command that is likely to close the connection. Only table creation and value insertion commands are there. Since the crash is abrupt, can't figure out the root cause.
Can anyone help me in analyzing this further?

Assuming it's a Linux box, try running the command with strace
strace -ff -o mysql.strace <your mysql cmd>
Log at mysql.strace.[PID] can show how far the execution went.

Related

mysql: unknown option '--skip-grant-tables'

I'm using tt-RSS as an rss reader running on a raspberry pi. Lately it's been running really slowly so I checked the logs to see the below error appear when starting mysql
Can't open and lock privilege tables: Incorrect file format 'servers'
So I googled it and found a post saying to use the skip-grant-tables option and repair the database(s) Post. I got as far as running the first command in the answer and now mysql doesn't work. It appears to be running but whenever I run mysql I get the following message mysql: unknown option '--skip-grant-tables' before being sent back to the prompt.
I cant seem to find any reference to this error anywhere and I cant seem to disable the skip grant tables option to go back.
I've rebooted the machine, restarted mysql and mysqld services and looked in the my.cnf file, where it does say [client server]
skip-grant-tables
If I remove that option and restarted the computer/services then mysql fails to start completely. Otherwise I'm stuck at the above error.
Any help in fixing the error and getting mysql working again would be much appreciated.

How to fix "too many open files" in MySQL?

I am very frequently getting this error in MySQL:
OS errno 24 - Too many open files
What's the cause and what are the solutions?
I was getting the errno: 24 - Too many open files too often when i was using many databases at the same time.
Solution
ensure that the connections to db server close propertly
edit /etc/systemd/system.conf. Uncomment and make
DefaultLimitNOFILE=infinity
DefaultLimitMEMLOCK=infinity
then run systemctl daemon-reload and service mysql restart.
You can check the results with the query: SHOW GLOBAL VARIABLES LIKE 'open_files_limit' and you may notice that the value has changed. You should not have any errno 24 now.
Please notice that the solution may differ from other OS/versions. You can try to locate the variables first.Tested with Ubuntu 16.04.3 and mysql 5.7.19.
In my case it was useless to setting up the open_files_limit variable in mysql configuration files as the variable is flagged as a readonly.
I hope it helped!
You probably have a connection leak in your application, that is why open connections are not closed once the function completes it's execution.
I would probably look into the application code and see where the connections/preparedstatement (if it's java) objects are not closed and fix it.
A quick workaround is to increase ulimit of the server (explained here) which would increase number of open file descriptors (i.e. connections). However, if you have a connection leak, you will encounter this error again, at later stages.
I faced the same problem and found a solution on another stackoverflow-question.
By running the following snippet with Bash:
ulimit -n 30000

Reason behind this error . ERROR! Manager of pid-file quit without updating file. In my sql

I am not looking for the workarounds . I eager about knowing what the possible reasons could be
You can try the following found at this link which worked for me: http://www.emreakkas.com/windows-tips/solution-manager-of-pid-file-quit-without-updating-file
If you are getting this error when you try to start mysql server, mysql is having a problem with one of the variables that you have in its configuration file my.cnf.
Manager of pid-file quit without updating file
First verify that this is true. Rename my.cnf to my.old.cnf and try starting the server again. If you do not know where my.cnf is, you can do “locate my.cnf”.
If mysql server starts fine when you rename my.cnf, it confirms that it is having a problem with your my.cnf file. Rename the file back to its original name and try starting the server. Once you get the “Manager of pid-file quit without updating file” error message, head to the mysql error log. This error log may be under your system’s log directory (/var/log/mysql) or under the mysql data folder (usually /usr/local/mysql/data). Tail the file to see the problem.

mysql chef database recipe fails on large file

"MySQL server has gone away". Hmm.
I am using vagrant and chef to setup my virtual development environment. I'm almost there, but on the last step chef fails when attempting to execute my external db_setup.sql file. I can execute this same script by SSH'ing into the virtual server and it installs without difficulty.
This is my problem code (in cookbooks/database/recipies/mysql.rb file):
# Query a database from a sql script on disk
mysql_database 'run script' do
database_name 'my_db'
connection mysql_connection_info
retries 3
sql { ::File.open('/vagrant/db_setup.sql').read }
action :query
end
The file is 6.9mb and the error I receive when I run vagrant provision is:
==> default: [2014-08-24T16:04:53-07:00] ERROR: mysql_database[run script]
(database::mysql line 50) had an error: Mysql::Error: MySQL server has gone away
For what it's worth, when I replace the db_setup.sql file with a smaller, simpler file that just creates a few empty tables, it executes without difficulty.
Any suggestions? Thank you in advance!
Many, many things can cause this error. In my experience it's usually an SQL file of over 1MB, or, the wait_timeout in your servers my.cnf is set very low (sixty seconds) needs properly tuned. When deploying my.cnf try a wait_timeout 86400 and a max_allowed_packet of "enough" to import that file.
For example:
[mysqld]
wait_timeout = 86400
max_allowed_packet = 1GB
PS. I would not recommend this high of parameters in actual production.
I worked around this issue by getting Chef to leverage the mysql command line tool instead of using Ruby to read the .sql file.

MySQL Server does not start after changing max_allowed_packet parameter

MySQL Community Edition 8.0.13 on Windows 10 Pro 32 GB x64
I am running the community server 8.0.18 (from the command line and not the service) and I need to set the max_allowed_packet value to higher than the default.
However,the server hangs on start with max_allowed_packet=16M, both when
change is made in the ini file, or
the value is passed as a command line parameter
Update:It seemed strange that the server would not start after a legal change - so I just saved the conf (my.ini) file without making any changes. And the got the same result
The ini file is as follows:
# The maximum size of one packet or any generated or intermediate string, or any parameter sent by the
# mysql_stmt_send_long_data() C API function.
max_allowed_packet=16M
The steps I followed are:
Install MySQL with advance logging and turn on all logs and without setting up a service
Start server by running mysqld : starts ok
Stop server by running mysqladmin -u root -p shutdown : shutsdown ok
change the value in the my.ini
Start server - server hangs
Full logging is on but nothing even gets written to the log. The last entry in the log is:
2019-10-24T14:47:56.916731Z 10 Connect root#localhost on using SSL/TLS
2019-10-24T14:47:56.916973Z 10 Query shutdown
2019-10-24T14:47:56.917224Z 10 Query
At this point, the only thing possible is to reboot, uninstall and then install again.
I have searched the forum for similar issues, and none of the previous suggestions apply/or work.
Issues resolved: Am posting an answer instead of deleting the question just in case it helps somebody else.
I had the conf (ini) file open in an editor (sublime/atom at different times) while I was starting the server. Finally I used notepad edited the file, closed it and the server started just fine.
I think the server is not able to load the conf file if it is open by another process.