phpMyAdmin migrate database

I’m making dockers for all my web applications. And most of my web applications are hooked up with databases. And where you have a database, you have phpMyAdmin. Anyway. I have this computer A with a very extensive database that I want to have now on a docker. The docker I will call B. What we do to have the database of A in B is to dump it first.

root@A ~ ## > mysqldump -u root -p --all-databases > alldb.sql

I assume we can ssh into the docker B, and scp or transfer files to it from another location. So now we simply load the database in the docker.

[root@B ~]# mysql -u root -p < alldb.sql

That’s it. My calendars, my web, all is in B as in A. But B is a docker 🙂

Advertisements

Blowing it up

– Fire! – It took us quite some time to start it, so we almost dance around it once we see a clear, sustained flame. It looks like the sea snow helped to reduce the air pressure, or vice versa, and now we can breath easier and speak easier. Or maybe we adapted, who knows. Under one of the sits of the amphibious rickshaw we found a flask with something that happened to be some kind of vodka, and now, we are celebrating. We are going up! We will fly back!

– It works! – I say. The sheets, loosely sewed, were growing under the heat like an insane white and green mushroom. We dismantled the floor of our vehicle so the fire was now in the middle of the rhombohedral body, and the bench of Paul and Luc, went missing. In fact, the parts were now contributing to the fire. We decided by gestures that it was an acceptable loose, and I guess that if we make it up the damage will be very easy to repair. – It works. – She says. I relax the strings tightening the ballon so it goes a little higher, over the canopy. Still flaccid, unfortunately. I stop looking at the thing to look at her, and I find out we look each other. I get her by the waist, but she is the one that comes face to face. We kiss. I close my eyes. This time, the kiss is expected by both of us, and we stay together for a while. I forget where we are, I forget what we do. But she opens her eyes first.

– It’s not enough. – She says. I look at the flaccid balloon. It’s floating, but there’s no pull. – It’s too heavy.  Maybe. – Maybe. I think. My brain is quickly making the math. Hydrodynamics, thermodynamics, please help me. We need more wood, I think. Or something burning in a more intense way. Where is the propane when we need it? Maybe I can dig up some oil somewhere?

– Let me go in. I look for something else to burn. Or I find another solution. – We separate. She smiles to me, and gently touches my three-day bristle. I didn’t shave for a while. Maybe she likes it. I need to ask her at one point. Her eyes are speaking to me. I’m sorry. I don’t want, but we can’t stay here forever. We could try coming back by walk, but only if I find suitable food, and if we abandon the rickshaw that we were asked to return. But OK, we could say in the trip we lost two guys also, so no big deal, right?

– I go. See you soon! – I leave her monitoring the fire and I head back to the Finger. After a few meters, I turn my head. She’s looking at me, smiling, like before. In her back, our balloon is resisting to get its shape. I cross the doorway again, the third time today.

Light my fire

I look back to our assemble, canopy rickshaw and all. She stands there, guarding it, smiling in the distance. I walk a little, almost swimming in the dirt. The air starts to feel too heavy to inhale it. And things are now floating, like small creatures, some kind of floating plankton. Or maybe they are just seeds falling from above, all together now. I remember something like that happening on Earth, at the bottom of the oceans. Sea snow, it was called. Each step I remember that I’m more than 4 Km under the sea level, and I marvel about. We did it. We reached the bottom of Matapan. Or it looks like the end of the road. Maybe if we follow the chasm, we will find out that 500 meter beyond us, a deeper abyss opens up. But it feels like it. And you have the Finger, like marking it, erected like a broken masculine member, curves and all. Maybe it feel all together from the sky. Like my green rope.

I enter inside. I see the stairs. They wait me. It looks like in the hall it’s a little bit darker than before, maybe because of the sea snow storm. I want to do it fast, so I go to the cupboard close to the stairs and kick it with all my strength.  A muzzled noise reaches my ears, a cloud of dust is released, but I achieve my goal, and the piece of furniture is now a pile of wood. Actually, the result is beyond my expects, since the splinters are minimal and the wood is in very regular, easy to handle slates. Plus some extras. I grab as much as I can for my trip back while I think about how could I quickly collect the lichens that I will use as fire starters. ..

She comes to help me. Her eyes are sad, but her face shows joy. Does she really thought I was not going to make it back? What did she see inside the finger that is scaring the hell out of her? Soon, we have a decent pile, in the right place, ready to be lighted on. It turned out that she was collecting lichens so I don’t need to check it all. I love it. Thankful, I test my lighter is still giving me a flame. But in a moment of inspiration, I hand it over to Pamela. The Doors. Se laughs, but in silence. She knows I like them.

– C’mon baby light my fire – I say. – C’mon baby light my fire. – We laugh together.

A kind of balloon

– Here.- Pamela looks at my bunch of sheets like if she’s looking at a pile of dirty clothes. – This – I give her the lancet. It will perfectly work to make holes. – nthis…  –  I found a roll of something greenish, like a string, rolled as a pile on the landing of the second floor. At the very beginning I was suspicious. Who put it there, on an easy-to-reach place, and how long ago? The upper floors were not visible because of the green fog, actually, the whole string roll could have fallen this way from above. As far as I know, the Finger could be open at the top.  She examines my funny green string, she pulls it, she tries to break it, and seems satisfied.  – OK! – she says. Now it comes the difficult part, the assembly. I gesture about it.

The canopy was going to be our amphibious rickshaw. I was expecting, at least, to be able to pull it up with our ballon so that we roll away this heavy land, on the way to the more comfortable territory above us….or something like that. I try alone to lift the ballon shell. Way too heavy! I look at Pamela, and she understand immediately what’s the problem. – Fire? – She ask. I remember the old, mysterious wooden furnitures I saw while exploring. Things like broken up cupboards or uneven chairs. Or the handrails. Will they burn? Probably! – Fire! – I say. – She looks around. Now that I look also I see there’s some dry lichen covering…almost everything. I scratch a little. Perfect. – Good! I get wood. – I say, pointing at the close by building. She grabs my wrist. – No! Wait! – She comes closer to me, and, without me expecting it at all, with a little lovely jump, she kisses me in the lips. Just that. A kiss. Maybe without any second message. But I melt anyway.

A leginon docker on CentOS 7 Part II: centos7AutoInstallation.py

selinuxinstallOn the previous post, we prepared a basic LAMP docker to hold a leginon installation.  I assume now you downloaded the installer for CentOS 7 and copied it to the docker via ssh or shared folder. We can simply run it. At the beginning it looks like this:

[root@dleginon]# python centos7AutoInstallation.py 
Current OS Information: CentOS Linux release 7.3.1611 (Core)
"root" access checked success...
====================================
Installing job submission server
Installing processing server
Installing database server
Installing web server
====================================

I choose “no” on would you like to install EMAN, Xmipp, and all the processing software. We don’t want to process in the docker. Note that the auto installer seems to try to install the database server and configure it, but we already did it. Unfortunately even being careful with the options, the installer fails with multiple errors. Additional work is needed. I created a wrap over the original installer, then customize the installer so that it doesn’t throw us errors. This is my wrap:

#!/bin/bash
echo " Changing phpMyAdmin to password-protected, cookie-based "
\cp config.inc.php.phpMyAdmin.docker /etc/phpMyAdmin/config.inc.php
echo " Please setup NOW the MYSQL root password"
mysqladmin -u root password
echo " Please test login on the phpMyAdmin web interface"
echo " Setting up my.cnf limits" 
\cp my.cnf.docker /etc/my.cnf 
echo " Installing missing packages. This may take some time "
yum -y install nedit gedit net-tools torque-client torque-mom \
ImageMagick MySQL-python compat-gcc-34-g77 fftw3-devel \
gcc-c++ gcc-gfortran gcc-objc gnuplot grace gsl-devel \
libtiff-devel netpbm-progs numpy openmpi-devel opencv-python \
python-devel python-imaging python-matplotlib python-tools \
python-pip scipy wxPython xorg-x11-server-Xvfb libjpeg-devel \
zlib-devel
### to have openmpi temporary and permanently available
echo "export PATH=\$PATH:/usr/lib64/openmpi/bin" \
>> /root/.bash_profile
export PATH=$PATH:/usr/lib64/openmpi/bin
echo " ..packages installed"
### database configuration
php -f leginon-db-config.php
echo " Intial configuration done. "
echo " Starting the autoinstaller..."
python centos7AutoInstallationCustom.py
echo " Autoinstaller done. "
cp config.php.myamiweb.docker /var/www/html/myamiweb/config.php
chmod 777 /var/www/html/myamiweb
chmod 777 /var/www/html/myamiweb/config.php

As you see, we copy two template files, my.cnf.docker and config.php.myamiweb.docker. The first one is simply the one we edited on the first part of this post. The second one is not so important, since it will be overwritten after the first run of the Web Tools Setup Wizard, pictured above. Basically, just change the host name and login type.

We need to have a look to the php file also. It’s just doing what you’re asked to do for the Database Server Installation. Let’s say your docker is called “dleginon“. My php file is like this:

<?php 
 $connection = mysql_connect( "127.0.0.1", "root", "docker" ) 
 or die( "Sorry - unable to connect to MySQL" );
 echo( " Congratulations - you are connected to MySQL \n" );
 echo( " Creating initial databases and users \n" );

mysql_query("CREATE DATABASE leginondb");
mysql_query("CREATE DATABASE projectdb");

mysql_query("CREATE USER 'usr_object'@'localhost' \
IDENTIFIED BY 'DOCKERLEGINON';");
mysql_query("GRANT ALL PRIVILEGES ON leginondb.* TO \
'usr_object'@'localhost';");
mysql_query("GRANT ALL PRIVILEGES ON projectdb.* TO \
'usr_object'@'localhost'docker;");

mysql_query("GRANT ALL ON leginondb.* TO \
'user_object'@'localhost'");
mysql_query("GRANT ALL ON projectdb.* TO \
'user_object'@'localhost'");
mysql_query("GRANT ALTER, CREATE, INSERT, SELECT, UPDATE, \
DELETE ON ON `ap%`.* TO 'user_object'@'localhost'");
mysql_query("GRANT ALL PRIVILEGES ON *.* TO \
'usr_object'@'localhost'");
 
mysql_query("CREATE USER 'usr_object'@'%' \
IDENTIFIED BY 'DOCKERLEGINON';");
mysql_query("GRANT ALL PRIVILEGES ON leginondb.* TO \
'usr_object'@'%';");
mysql_query("GRANT ALL PRIVILEGES ON projectdb.* TO \
'usr_object'@'%';");

mysql_query("GRANT ALL ON leginondb.* TO 'user_object'@'%'");
mysql_query("GRANT ALL ON projectdb.* TO 'user_object'@'%'");
 
mysql_query("GRANT ALTER, CREATE, INSERT, SELECT, UPDATE, \
DELETE ON ON `ap%`.* TO 'user_object'@'%'");
mysql_query("GRANT ALL PRIVILEGES ON *.* TO 'usr_object'@'%'");

mysql_close();
 echo( " ...done \n" );

?>

The user “usr_object” is having the password “DOCKERLEGINON“, while the root docker is having the password “docker“. Be aware that inconsistency on root and  usr_object users on the database will lead to errors. Now what is centos7AutoInstallationCustom? I will not post it here (it’s too long) but basically it’s the auto installer you downloaded minus the system calls and minus the last lines that are opening the browser. I will not post it here, just modify it yourself.

Now we need to run the Web Tools Setup Wizard.  If your docker is called dleginon, open your browser pointing to http://dleginon/myamiweb/setup/ and use Database User: usr_object, Database password: DOCKERLEGINON. It is recommended to restart the docker first, in case you didn’t do it. Once you’re done, you should be able to log in as Administrator onto the myamiweb.

Are we ready to go? Not yet. If you ssh into the container to run start-leginon.py, you will get the next error:

leginon.project.NotConnectedError: 
(1045, "Access denied for user 'root'@'localhost' 
(using password: NO)")

This is due to an unconfigured /etc/myami/sinedon.cfg. Edit the file, and change the username and password so that start-leginon can access the database. If you run it afterwards, you will get this error:

RuntimeError: Must create at least one project 
before starting Leginon

To get rid of this one, go to myamiweb, and create a test project. Then run start-leginon.py again. Now it should work, and if not, let me know 🙂

Which way up?

– How? – I just reached Pamela, slowly moving in the soup we were currently. She was back fully dressed. She seemed a little bit tired while pointing up. Her energy is gone. She doesn’t shine anymore. Maybe she realised how stupid was to do what we did, that is, to come here without any escape plan, just for the sake of the experience. And what a experience, to move in an atmosphere that feels like a sticky blanket wrapped around your body. I can move, but after each move I need to convince myself that I should not simply fall on the floor and stare at the green sky. Now I see the Finger. His tip is lost in the mist that became our firmament at this moment. I don’t remember having a good night. A traditional one. Maybe that’s why I fell in the bed. We lost the feeling of time when we lost the moon and the sun. Maybe we could find a way up inside the tower?

I point it. She nods. Acknowledged. But. – No. No back in. Don’t. – She looks into my eyes. What is that? Fear? What did she find in? OK, we will have time to speak about it on the way up, I hope.

I’m a physicist. I know hot air goes up. And here is very hot. So how about making a balloon? I do my best gesturing it. We save words. She gets the idea pretty fast. A balloon! She smiles. But. – How? -She repeats. I point at the Finger. – Sheets. – I say. Luckily, we will find something to sew them. She shows me a face. She will not help if I go in. – I will. – I manage to say. We can use the amphibious rickshaw as a gondola. I point at it. She nods. Happy again! It’s important to believe a plan is going to work to make it work. Like my plan to get closer to Pamela. Again.

Inside & outside

I don’t know what I was expecting. Some kind of ancient temple, maybe all the walls covered with mysterious glyphs obviously not written for the humans to understand them. Maybe I secretly was thinking that to go back to System Earth was as simple as crossing the apparently black doorway of the Finger. Maybe I was thinking I was going to wake up, back in my anodyne routine, moving like a zombie to the kitchen and the coffee machine waiting me there to turn it on. But I turn out that that was the dream, and this was the reality.  Inside, the Finger was just another typical Yellow Earth building, fit for humans (or should I say humanoids?) but without personality. Just a big empty shell, ready to be occupied by us homeless ermitage crabs.

The hall had however some stairs. They were not gorgeous, they were even common. Suddenly I had a vision. This planet was built by insects, and the structures just happen to meet human standards, so the finger was like, a human-size anthill. But then, what happened to the builders? Were they eaten by some anteater God? Pamela gently pushed me forward, to move me out of my dreaminess… and I climbed them. Why not, we were already quite far. It looks like during my mental trip to Fantasia I became the head explorer. Nevermind. The second floor was at my reach, once there, I will leave the french guys, Paul and Luc, the exploring part.

– What we want. – I moved my lips more that really saying it. – What we look for. – The air was even denser inside the Finger. I was feeling like I was about to be able to swim the air instead of walk, so think it was.

– I …have …no …clue. – Pamela said. Gosh, I can see her nipples are hard. Why? Is it the moisture, or the situation? I’m not excited at all… – May…be… we.. can… try… each door, or cupboard, or something. – I can’t say speaking is easy here, and now I realized how quickly we agreed on starting our trip.  Fortunately for us, in the same way it will be quite smooth to take any collective decision. It will not be discussed. I hope.

– Right. – I decide to help Pamela. – Good plan. – She laughs in silence. Opening the mouth is hard, climbing stairs. Like if I have the lower jawbone sticked with chewing gum to the upper one.  – We meet out. – I manage to say. They all nod. We’re on the second floor. We have four doors around the staircase. How convenient, I can only thing. Luc and Paul walk together to the furthest doors, I take the closest one, and Pamela the next.

My room is unfeatured. It’s pity to be in an amazing place, that is, another planet almost, and find such a common thing like a king-sized bed fully prepared. I’m in one of these rooms that repeat around the City, if you’re lucky. How they were calling them in the XX’s? An IKEA display. It looks like one decorative display of a furniture shop. No personality, but perfect. Like an entelequia, a perfect one-room habitacle, waiting to be populated by his humanoid. But I digress. I then check the consistency. It’s OK, despite of the depth and so on. I give it a try. And I lay there, staring at the ceiling, trying to understand what the hell am I doing 5 Km under the sea level, until my eyes give up.

Of course I wake up and go out. Of course I check who’s around in the Finger. Nobody, apparently. I go downstairs as far as I can – I don’t want to look scared, but it scares me like hell to be left alone here – and I cross back out the main doorway.

First thing I say is Pamela. She’s staring at me from a safe distance. She’s alone. I manage to shout “Alone?” and she nods and waves me to come to her. Thing that I do without remorse at all. After all, I just met those guys, explanations can come later.