Why is the init file not populating Memory Tables in MySQL? - mysql

For optimizing system performance, we are storing a few static tables on RAM (copies of which does exist on the hard-drive as well -- on the MyISAM). Now, as we all know, when the server re-starts all data on RAM gets deleted. Hence to avoid that we created an init file that has 4 SQL statements.
Please note that each SQL statement exists on a separate line, ended with a semi-colon (;) and there are no comments anywhere --- so from my limited knowledge, I believe that I have avoided making some basic mistakes. However, when I re-start MySQL manually from the command line to test it, I see that the memory tables are empty. There are no issues with the initfile itself, because when I execute the initfile manually from the command line, the data gets populated without any issues.
Any help in terms of resolving this will be much appreciated!
Thanks!
Udayan

Something is not right here.
Just to check, I tried restarting my local mysql server using /etc/init.d/mysql restart. And, it started up as running by the mysql user (not root).
So, we will need the following to try to figure this out because I am just about positive that the problem is either that the file has the wrong permissions or it is in a location that the user running mysqld does not have access to.
What version of Linux are you running?
What is the version of mySQL that you have installed?
Is 'init-file=' in the right section of my.cnf?
What is the output of 'ps -ef | grep mysqld'?
What is the output of 'ls -lrt /tmp/initfile.sql'?
What did you mean by 'There are no issues with the initfile itself,
because when I execute the initfile manually from the command line,
the data gets populated without any issues.'?
I cannot help but think that it is a permissions problem. So the fourth and fifth answers are the ones that I am most interested in.
You should add all of these answers to your question - so that people have everything they need to help you solve your problem.

Appreciate all your suggestions but I have figured out what the issues were.
In the SQL file I needed to mention which database that init-file should populate.
I had trailing semi-colons in the SQL statements -- apparently that is not a good idea.
Once I made these two small changes, everything started working fine.
Again, thanks for the pointers!
Udayan

Related

DBeaver - missing procedures in MySQL database

I have connected to my work database via DBeaver. Recently colleague told me about a procedure that lets me check newly added entities through our front-end.
And I can't find it in the list of procedures, nor using this query:
SHOW PROCEDURE STATUS WHERE Name LIKE '%name%'
I have the same connection settings as my colleague's, same user, etc, but he uses DbForge and I use DBeaver, cause at some point of time DbForge began having too much restrictions for free version (I wasn't simply able to execute queries), and the older version my colleague gave me didn't install in Windows 11.
So, I'm thinking may be there's some settings in the DBeaver that hide certain stored procedures, or I need to adjust connection settings.
Does anyone has clue on this?
Or may be someone could suggest some alternative to DbForge, which allows to execute queries in the free version and to set colors to connections (I find that thing convenient), and possibly doesn't have this problem, may be because of being more MySQl-oriented.
Thanks in advance!
I've tried to open connection settings and check out the additional parameters there, but can't seem to notice anything relevant.
Ok, seems like there was misunderstanding between me and my colleague, and he actually meant some another DB Server, but with same User/Password combination. Thanks for the comments, that also helped in finding the cause. I really did install MySQL Workbench, saw the same picture in there, and started wondering what else it could be and reading our communication again.
My mistake) The question is no longer actual.

Only one mySQL database loses connection

I am trying to drop one of my databases in mySQL, but I keep getting error 2013: lost connection (this occurs with other queries in this database as well). However, any other database works fine; I can perform queries and delete databases and tables easily.
I've tried googling it, but everything I've seen has essentially said that this lost connection is because of a large or complicated query.
My code is just
DROP DATABASE employees;
However, when I expand that database, it also says Tables/Views/Stored Procedures/Functions cannot be fetched, if that helps (once again, my other databases don't have this problem).
I created this database in Jupyter notebooks using mySQL python connector, and the others I created directly in mySQL, but that is the only real differentiating factor between them.
Ok, I figured it out. Turns out if you're running the code in Jupyter Notebooks and try to perform any actions before closing the cursor, it won't run. (I forgot to run the cell with mycursor.close()). Thanks!

No changes detected in mysql

I been using mysql 5.6 for a while now,
Sometimes when I make some changes in the procedure , table or function and try to save them MySQL refuses to save them and shows a error message like "No Changes detected". here I am not talking about changing cases or managing spacing. Even If I add some new column and add new condition in the procedure its unable to detect the change
Can anybody help me out with this MySQL bug
I have even upgraded to MySQL 5.7 but still problem persist.
I overcome this bug by removing the "DEFINER=root#localhost" part from the editor and then click on "Apply". It works 99% of times.
Eg: For a function or procedure, below is the declaration you see at top. Just remove the DEFINER string as described above and try it.
CREATE DEFINER=root#localhost FUNCTION/PROCEDURE
Since this is not a MySQL server error response, I assume you are trying to update your procedures with the MySQL visual tool workbench (http://www.mysql.com/products/workbench/)
I found bug reports on mysql.com pointing out similar issues. http://bugs.mysql.com/bug.php?id=68434
Those might be fixed with the latest version 6.0 of MySQL workbench.
If not, a possible workaround would be to drop and recreate procedures.
If you are using MySQL Work bench this means that the SQL script is identical to the copy in the database.
This generally happens for 1 of 2 reasons
Either the Files are Identical, or the script failed to parse as valid SQL and its has then defaulted to the original script. if you check the message log then the second one should say
Action:Apply changes to [scriptName]_SYNTAX_ERROR
Message:No changes detected
this can be confusing as the Commit Dialogue only displays the message not the action

Table not viewable in MySQL DB, query runs fine

I have a sql query done by someone. I cannot seem to see the table where query is reading from, but offline, the table is in the same db. The dbconfig is the same offline and online.
Is there any way I can find where the table is, or unhide if hidden.
Thanks Jean
This sounds like a permissions issue. If you're the database administrator, login as root to see all the tables that exist. (If you can't see it as root, it just plain doesn't exist.)
If you're not the database administrator, contact whoever is to get access.
you can try running the query "show full processlist;" which will show you what connections exist, what database they are connected to, and what query they are currently executing.
You can also turn on query logging by adding "log = /path/to/logfile" to the config file or "-l logfile" to the mysqld command line and watch the queries executed there, though note that this can be a performance killer.
Please post the query. Some points to consider -
Maybe you are not in the correct database. Change to that database & try again.
Maybe you don't have permissions to log into that DB. Your script has (thanks to correct username, password).
That's all I can think of for now. Post your query so answer can be more constructive...
Thanks issue solved.
[edit]
Sorry guys...
#pekka ofcourse, had to jot quickly to close the issue.
I was auditing couple of servers, and noticed that one particular table in a db was missing, but queries was fine. It was on one server, which had nothing to do with the db. I had root access, but could not see anything, but a test db.
Thanks all for your help, as you all have been. Every answer is equal to a correct answer, and I am unable to mark it correct. Therefore I have given an upvote for all.
Thanks again

What would lead to an "Unknown object in backup file" problem when restoring a backup of a MySQL database?

Unfortunately, the problem is not more specific than that. I've found a few examples of people reporting similar problems by doing a Google search, but I can't find the part of the restore that is actually causing the problem, which might help me track it down on my own.
Suggestions for either resolving this problem or being able to track down the root cause would be appreciated.
There's one bug logged at bugs.mysql.com that references the error you describe:
"Bug #37253 Unable to restore backup file containing BLOBs"
The solution described in that bug is to increase the max_allowed_packet in the MySQL server configuration. The user confirmed that raising the value to 100M allowed him to restore his database.
ANOTHER FIX
I also had this problem! The answers online didn't seem to help (max_allowed_packet and others)
Here's what fixed mine:
Instead of running the Restore function, I imported through MySQL Migration Toolkit (installed with GUI Tools on Windows).
The Migration Toolkit also failed, but had descriptive errors in the Log on the final page. In my case, it was a few incorrect Date fields in my data (usually "0000-00-00") that wouldn't migrate correctly.
Fixing these dates in my tables solved the Restore problem.
Hope this helps somebody else out there.
I have had something similar in the past- it has something to do with how it was backed up. I think some applications put invalid comments in the backup files which cause errors.
My suggestion- if you are stuck trying to restore those files- is to incrementally start backing up from sections of the backup file and find what is causing the problems- which from what I recall the case for me was that they were some text in the file that was inconsequential to remove.