How to disable MySQL from autostart when Ubuntu bootup
Answer:
A newer version of MySQL use upstart to autostart when system bootup, to disable it
# sudo mkdir /etc/init.disabled # sudo mv /etc/init/mysql.conf /etc/init.disabled/
Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.
How to disable MySQL from autostart when Ubuntu bootup
Answer:
A newer version of MySQL use upstart to autostart when system bootup, to disable it
# sudo mkdir /etc/init.disabled # sudo mv /etc/init/mysql.conf /etc/init.disabled/
Generate random data in MongoDB
Answer:
You can use the following method to generate random string into a collection in MongoDB:
function randomString() {
var chars =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
var randomstring = '';
var string_length = 100;
for (var i=0; i<string_length; i++) {
var rnum = Math.floor(Math.random() * chars.length);
randomstring += chars.substring(rnum,rnum+1);
}
return randomstring;
}
for(var i=0; i<2000000; i++){db.test.save({x:i, data:randomString()});}
How to get the total database index size of my MongoDB
Answer:
In you mongo shell, execute the following command:
var sum = 0; db.getMongo().getDBs()["databases"].forEach(function(x) { sum += db.getMongo().getDB(x.name).stats().indexSize }); print(sum)
Check how long a MongoDB instance was running
Answer:
To see how long a MongoDB instance was running, you can login into the mongo shell, and enter
db.serverStatus().uptime / 3600
The above command reply the value in term of hours.
How to get the startup warning from MongoDB?
Answer:
The easiest way is login into the MongoDB using the shell, enter the command:
db.adminCommand({getLog: "startupWarnings" })