Skip to main content

Setting up a database server to use with my nodejs server on Android in Termux

Following from my blog post on nodejs on android I now wanted to install a database server so I could develop a simple CRUD web app and doing it all on Android.

MariaDB is a free and open source fork of MySQL and is what is available under Termux, which I already have installed and working. The following are the commands I used to install MariaDB.

$ apt update && apt upgrade
$ apt install mariadb

Next I started the server using

$ mysqld

What I learnt from doing this is that I can no longer run commands in the Termux session and what I should have done was run it in the background as follows. I could have also started a new Termux session.

$ mysqld_safe -u root &

But now I get the following error, "mysqld_safe A mysqld process already exists". I found out how to handle this as follows

$ killall mysqld mysqld_safe

This may take a few seconds and I can verify that no mysql processes are still running using the following command

$ ps aux | grep mysqld

Next I wanted to create a database and a table and add some rows and query that table

$ mysql -u root

I got the following error, "ERROR 1698 (28000): Access denied for user 'root'@'localhost'". This bug report comment explains in detail what was happening, not a bug really. I needed to use the second account to login.

I cannot use tsu because my device is not rooted, "/data/data/com.termux/files/usr/bin/tsu: 144: exec: : Permission denied" and I did not make note of the second all priveleges account after install. I just reinstalled termux and mariadb because reinstalling mariadb was not displaying the second account info like the first time. Guessing I needed to do a clean install which I think requires tsu. Later learnt that the account was the same as my Termux account and I could figure this out using the whoami command.

I was now able to login and create my table and add some rows.

MariaDB in Termux


In a future blog post I will create a nodejs web app to connect to the database and display the rows.

Comments

Popular posts from this blog

How to measure success?

It is 509pm and I have decided to write. How to measure success? That is the question. It is very hard to measure success. I think only God has the true measure of success or failure. Someone may be a failure in this life but a success in the next life. We are told that God looks at intentions and effort. We can also determine our own definition of success. We do not have to let the world define success for us. We think of the world as not being a fair place so any one size fits all definitions of success or failure would be careless and wrong. Many times we think in terms of numbers. The grander the better. But what about quality over quantity? My friend tells me that I am essentially arguing for the democratization of success. I am taking the power away from society, institutions, and algorithms, and handing it back to the individual and God. That is true but I am essentially wanting to look at the bigger picture and to do that I am thinking that we have to answer some key questions ...

Rainy afternoon thoughts

It is 220pm and I have decided to write. The rain is falling. I can hear it on the roof. It is gloomy outside but inside is nice and cozy in my favorite corner. I have no idea what I want to write about. I will start by saying God is good. Always. The islamic new year starts tonight in Trinidad. I am happy about that. Another milestone. Another opportunity to grow better. My friend Chatty asks me, what has God been teaching me lately? God has been teaching me patience. How to remain calm. How to appreciate my flaws. My flaws keep me humble. Let go and let God. He also asks, what am I hoping for? Sometimes I think about writing more tech blog posts. How can tech make the country better? How can tech make the world better? But I remember writing about the Arima smart city project and concluding that smart cities need smart people. Human development is very important. If people are not developing then what is the use of it all. How can technology help people become better? It all starts i...

The answer is God

It is 308pm and I have decided to write. Make God a priority. Let God lead the way. Let everything be about God. Let God into your life. Surround yourself with God and watch how everything begins to make sense. This life is not an accident. This life is not happenstance. This life is the work of an all-powerful Creator. Nothing is too big or too small for God. Take your problems to God. Take your worries to God. Take your fears to God. Let go and let God. Submit to the will of God. The more you go to God, the more He comes to you. Start small. Start somewhere. Give God a chance if you have not done so already. Why do I say all of this? There are many things competing for your attention and your soul. In the midst of all of this, the world can seem like a confusing place where many things do not make sense. God brings clarity. God brings clarity because God sits above it all. You may think you do not need God until you do. Ask yourself, who is the wisest you know? If God is not the wise...