Soemarko Ridwan

iOS & Web Developer ⟡ Coffee Addict ⟡ Scuba Diver

Buy Me a Coffee at ko-fi.com

Three Ways to Migrate MySQL Database

1. phpMyAdmin:

  1. Export your database: Go in phpMyAdmin, select your database and go to Export tab. You should see a set of options, by default both data and structure should be checked so your export will contain the database structure and the actual data in the database, for transferring the database you should use the SQL format. At the bottom of the page there should be a for that will let you specify the file name, and compression. If you select “none” the export will be dumped in your browser, this is not recommended because you would have to copy that sql and then paste it in phpMyAdmin on the new server and if the dump is large it may not work.
  2. Import the database on the new server: Click on the SQL button in the left sidebar in phpMyAdmin. In the pop up window that just showed up go to “Import files” tab. In there you will be able to import the sql file you get from your first server. The problem with the phpMyAdmin approach is that most web server configurations limit the maximum size of files you upload or the maximum execution time of a php script or the maximum memory that a PHP script can use. So unless you have small dumps (under 10 MB) this method is not recommended.

2. Command line mysql client tools: if you have shell access to any of the servers ( ssh or telnet ) you can use the command line mysql client to either export (dump ) or import a mysql database . To dump the database use mysqldump:

mysqldump -u "your_username" -p —lock-tables \\
"your_database" > your_database_dump.sql

I added —lock-tables there so that it puts a read lock on all tables while running the dump process to make sure that no one can modify the databases and create inconsistencies in the dump. If you have more then one database that needs to be exported you can use the —databases option like this:

mysqldump -u "your_username" -p —lock-tables \\
—databases DB1 **[**DB2 DB3…**]** > your_database_dump.sql

If you want to export all of your databases you can just replace —databases DB1 [DB2 DB3…] with —all-databases

To import the databases on the new server you can try the phpMyAdmin method or if you have shell access (preferable ) you can use the mysql client. If you’re going to use the mysql client you will have to transfer the dump file to the server ( use ftp or sftp/scp ).You might want to compress the file before transferring it

    bzip2 your_database_dump.sql
    scp your_database_dump.sql.bz2 user@newserver:~

and after the transfer finished, run this on the new server: mysql -u “your username” -p "your_database" < database_dump.sql

Or if your dump includes a “CREATE DATABASE” statement ( usually when a file contains the dump of more then one database or if you exported you databases using —all-databases or —databases options ) then you can just do: mysql -u “your_username” -p < your_database_dump.sql

This method works with very large databases.

3. File transfer: The MySQL server stores database structure and data in regular files on disk. This means that if you can login on the server with privileges to access the folder where the databases are stored ( usually /var/lib/mysql) then you can just copy or transfer then to another server via ftp, scp, sftp, or rsync.

Before doing so, you have to make sure no one is writing to the databases that you want to transfer so you should put a read lock on them.

FLUSH TABLES WITH READ LOCK

Leave the mysql client running and then copy or transfer transfer the files. After the transfer finished, exit the mysql client or type:

    UNLOCK TABLES

To release the read lock.

This method also works with large databases, and it is faster than the previous method in this case MySQL server does not have to parse and process queries or recreate indexes because the whole data including indexes is transferred from the old server.


Code Monkey

No, it's not about that Jonathan Coulton's song, though it's somewhat related. It's about Chinese developers that are burning out before 30 years old;

He is so focused on keeping his start-up alive that he can't sleep at night. She was asked in an interview if she would be willing to break up with her boyfriend for the job. A young couple want their own family but have no energy for sex after work.

...

Tech firms in China typically expect their employees to work long hours to prove their dedication. That means a so-called 996 schedule: 9am to 9pm, six days a week.

...

There are many derogatory slang words for software developers in China, such as manong (码农), which literally means “coding farmers”, and chengxuyuan (程序猿), a play on words that translates to “programming apes.”

That last part, "programming apes," it's basically code monkey, the song was released in 2006. It's nothing new. But other than that, everything else is pretty fucked up. The thing is these situations aren't that far off here in Indonesia, especially if you're a lower ranked developer. The code monkey. The companies here won't force you to do the 996 schedule, but they just won't pay you enough so you'll need to pick up some side gigs to cover basic living costs.



Network Wide Ad-block
Network Wide Ad-block

As the tagline said, blackhole for internet ads. Ever since the day of the original Adblock (even before ABP), I no longer able to browse the internet without some kind of ad blocking. But today, where most things turn into some kind of app, ad blocker doesn’t really work outside of browser. And that is where pi-hole comes in.

I never really took to Raspberry Pi, unlike Arduino, Pi doesn’t really inspire me to do anything with it. But I bought a couple of Zero W, cause it was dirt cheap, and they sit on my shelf for a year or so. Until I came across dietpi, a super lightweight, extremely minimal version of the OS. And it is designed to work headless right off the bat. I literally look for things to do with my Pi. Again, uninspiring. So I just install CUPS, and turn my USB printer into wifi printer. That’s it. These days, we hardly print anything anyway.

Until I came across pi-hole in one of the list of supported software in dietpi. Seriously, dietpi is a brilliant OS. literally just hit a checkbox, and you have pi-hole installed. Make sure you have static IP for the Pi device, and set your router DNS to the pi-hole, BAM! You’re done. Most ads are gone. Even the one in your apps. Since pi-hole is blocking on the network level, it won’t be as clean as a browser extension blocker. The boxes will still be there, but they are just empty boxes or a placeholder messages.

After using pi-hole for 3 days, turns out 30% of my queries are blocked. OMFG! a third of my internet queries are either ads or trackers. Seriously, pi-hole is so good that it’ll be worth it for you to get a $10 Raspberry Pi just for running it. Think about it, it’s like having $10 once for a lifetime service of ad blocking within your network.

A little caveat when running pi-hole under dietpi, it’s a bit tricky if you want to run dnscrypt as well (still way easier than compiling and installing everything on your own), personally, I just wait until dietpi added dnscrypt to their supported software list. Up until a few days a go, I was running nothing other than pointing my DNS to CloudFlare’s 1.1.1.1. Pi-hole is a huge step-up. I can wait a bit for dnscrypt.


Uber & Lyft == GoJek & Grab
Uber & Lyft == GoJek & Grab

An interesting post from Washington Post about Uber / Lyft;

But Lyft and Uber are a different story. They’re not selling a song or a movie that can be endlessly replicated for little incremental cost; they’re selling a physical service that’s pretty expensive to deliver. At some point, we’re going to have to pay for it.

Heavy users of ride sharing should start getting used to the idea that the cost will soon go up, and plan their lives accordingly. And investors should prepare for demand to drop when customers and drivers discover the true price of the service.

I have told and repeated that to many folks in start-up world around me about GoJek and Grab. Literally the clone of Uber or Lyft in Indonesia, and some of Southeast Asia for Grab. The days of having food delivered to our door cheaper than the parking fee will go away, sooner or later.


Softaculous + Bludit
Softaculous + Bludit

Awhile ago I’ve posted about automating Bludit’s backup, but you know what guys? My cheap ass shared hosting has a better way to do it. Turns out the bug I mentioned in that post it was my own doing. When I wanted to test Grav as my blog, I installed it through Softaculous and I turned on auto update. That’s why my Bludit installation kept being overwritten by Grav.

So I fix that, and upon further investigation, I found Bludit on Softaculous, which I can import my current installation into it. And through Softaculous, I can set up periodic back-up. Then, this is what’s blowing my mind, I can create a staging copy of it. It basically just making copy to another directory, but it’ll change my current workflow. I do all the needed changes on the staging site, then hit the “Push to Live” button. After a quick test, it’ll spit out an error, but it still works.

The only downside I’ve seen is that the analytics on live site is overwritten by the one on the Staging site. I don’t really care about that. If I want to be creepy and track everyone that come to this site I just use Google’s analytics, but I really don’t care about analytics at this point.


On Money
On Money

Upon returning from my scuba trip to Raja Ampat, what I normally do is editing the clips and compile them into one-minute video for my instagram. While doing that, I like to catch-up on my youtube, I played them on my iPad as a background. But one of the recent video from Casey Neistat caught my attention.

The whole 10-min video can be sum up by a single line from Kanye’s Good Life;

Having money's not everything and not having it is.

This really resonates with me at this moment, as I mentioned on my yearly theme post; I’ve been coasting with my past income for awhile now, but now it’s time too aim for more stability especially in terms of income. Again, this is my year of adulting.

Being a digital nomad is current new hotness. I’ve been a subscriber to /r/digitalnomad for awhile now. It seems like an ideal situation for me. I’ll have most of the flexibility I’ve been having for awhile now, but I’ll also have a stable income. And even more stable than most, cause having dollars as income will shield me from the instability of Rupiah, along with the shoddy political climate we’re having right now.

So, up next is me putting my past projects here on this site so it can be both my portfolio and CV. Then apply to tons of companies that accepts nomad developers. Let’s see if not having a Linked-in profile will actually bite me in the ass.

Wish me luck!