How to save Steem blockchain to MySQL?

Ever wanted to access Steem data easily. Steem developers got you covered, there are already services to make your life easy and get you started with developing applications on top of Steem.

SteemData, SteemSQL, many more services that offer you tools and services to get started.

Get your own

If you want to build and host your own database for your application you can do that as well. SBDS (Steem Blockchain Data Service) which is being developed by Steemit and it is already fully functional.

Instruction on github straight-forward and uses SQLite by default because sbds has api routes built-in to query data. And you want more custom queries and have data in mysql database, you can try below steps. I have couple instances running for eSteem users and upcoming features.

All you need is virtual machine or local one with docker installed.

Steps

Here are the steps I did on my sbds setups:

a) docker run -d --name steem_mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=password -e MYSQL_DATABASE=steem mysql

This will run mysql docker instance which we can use to hook up our sbds docker.

--:--

b) docker inspect --format '{{ .NetworkSettings.IPAddress }}' steem_mysql

This will show you ip address of mysql docker instance which you can use below

--:--

c) git clone https://github.com/steemit/sbds

Clone SBDS source code from github

--:--

d) cd sbds && nano Dockerfile

Edit docker file by adding mysql connection url

--:--

e) ENV DATABASE_URL mysql://root:password@ip_of_mysql_docker:3306/steem

Change line 3 in Dockerfile to above, you can add/setup your custom user credentials instead of root for your mysql instance if you prefer safer storage.

--:--

f) docker build -t sbds .

This will build sbds

--:--

g) docker run -p 8080:8080 -p 9191:9191 --name sbds-instance --link steem_mysql:mysql sbds

This will run sbds and link to mysql docker instance.

--:--

That's it!


Now you can wait sbds to sync up and save all blockchain data to mysql for you.

You can connect to mysql instance via your virtual/local machine IP, mysql credentials because instance exposed 3306 port. SBDS ports are also exposed so you can use SBDS json-rpc requests as well to query the data you need.

If you are developing website, web application, business or any application, I am sure local copy of blockchain helps you build all sort of stuff and get stats easily. Read previous post to learn why you should build on top of Steem.

Steem On!


vote, reblog, follow, vote witness good-karma

H2
H3
H4
3 columns
2 columns
1 column
106 Comments
Ecency