pdufault / mysqlfragfinder Goto Github PK
View Code? Open in Web Editor NEWfinds your fragmented tables...and defragments them
finds your fragmented tables...and defragments them
Hello,
If I try to run it from cron I get:
tput: No value for $TERM and no -T specified
how to... ? thanks and Happy New Year
Hello,
your script doesn't work as expected on databases with special charasters like dash (the "-") in their name.
The problem is in this:
fragmented=( $("${mysqlCmd}" -u"$mysqlUser" -p"$mysqlPass" -h"$mysqlHost" --skip-column-names --batch -e "SHOW TABLE STATUS FROM $i;" 2>"$log" | awk '{print $1,$2,$10}' | egrep "MyISAM|InnoDB" | awk '$3 > 0' | awk '{print $1}') );
If the $i equals for example my-database, the query will end in error. you have to add escaped quotes like this:
fragmented=( $("${mysqlCmd}" -u"$mysqlUser" -p"$mysqlPass" -h"$mysqlHost" --skip-column-names --batch -e "SHOW TABLE STATUS FROM
$i
;" 2>"$log" | awk '{print $1,$2,$10}' | egrep "MyISAM|InnoDB|Aria" | awk '$3 > 0' | awk '{print $1}') );
(Adittionaly I added the Aria datastore, because I use it a lot and the OPTIMIZE works just like with the MyISAM)
However, I'm not sure how specific the problem is. Maybe it's just my problem :). But after this fix, script sucessfully optimizes all my databases. Before the fix, there was 90% of fragmented tables untouched.
Regards,
Vlastimil Kotas
Hi,
I have noticed a few issues with the .my.cnf part of the script.
Firstly, the wrong variable is set on line 45: mysqlpassword:
mysqlpassword=$(grep password= < "$HOME/.my.cnf" | awk -F\" '{print $2}');
It ought to read:
mysqlPass=$(grep password= < "$HOME/.my.cnf" | awk -F\" '{print $2}');
Secondly, in my .my.cnf the password is passed with "pass=". I understand this can be done two ways but it would seem that it could be an idea to make both possible.
This is my original configuration file, which works fine with normally:
[client]
pass="[deleted]"
user=root
Also, the script failed to pick up my user name because it wan't enclosed with quotation marks. So, I had to change my configuration file to:
[client]
password="[deleted]"
user="root"
It could be an idea to make the script a bit more tolerant.
Niklas
Hello,
i have a problem with this script, i run the script wihtout problems and i sais to me:
N tables were fragmented, and were optimized.
But if i run again, also only in check mode:
Checking XXXX ... found N fragmented tables.
In phpmyadmin all tables overhead is 0, so my question is: after the script my tables are really optimized or not?
(i know, sorry for my bad english)
Thanks!
Hi,
I am on FreeBSD, I dont have bash, but using sh. Any possibility to port this script also for sh environment ?
Thanks.
I run my MYSQL on port 3319, had to implement the --port
along with the --port="$mysqlPort"
on each command. Can't do a pull request right now, but the modification isn't hard at all.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.