Tagged: android

Resetting MariaDB “root” Password on Termux

I just started learning Laravel framework for my self-interest and wanted to play with it on my Galaxy Note 8 since I already had Termux installed on it. A tutorial I found from Google search uses mySQL so I installed MariaDB with the following command:$ pkg install mariadb

The installation was successful, but when I tried to log in as root with no password, it failed with ERROR 1698 (28000): Access denied for user 'root'@'localhost'. I tried various passwords but none was successful. So, I searched for a solution.

Disclaimer: The information described here is from Termux Wiki. This information below is solely used for my purpose and may not be suitable for others.

Post Installation Tasks:

After the first login attempt, I realized that it was not connecting to mysql server because of the following error message:$ mysql -u root -p Enter password: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/data/data/com.termux/files/usr/tmp/mysqld.sock' (2)

Was mysql server not running...? $ ps -aux | grep mysql xxx 8451 0.2 1.4 560836 79496 ? S

It looks to me, it's running fine. Is mysqld.sock file missing from the directory?:$ ls ../usr/tmp/ $

Ok, the directory was empty. So, I manually started mysql daemon with the following command:$ mysqld_safe -u root & [1] 8379 191029 20:48:14 mysqld_safe Logging to '/data/data/com.termux/files/usr/var/lib/mysql/localhost.err'. 191029 20:48:14 mysqld_safe Starting mysqld daemon with databases from /data/data/com.termux/files/usr/var/lib/mysql

After this, mysqld.sock was created.$ ls ../usr/tmp mysqld.sock $

Resetting root Password:

According to the wiki, the mariadb installation initializes the database with 2 all-privilege accounts, root and my Termux local user. With this local user, I can reset the root password. (But is there a point of resetting the root password at this point since my local user also has all privileges?)$ mysql -u $(whoami) Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.4.6-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]> use mysql; MariaDB [(mysql)]> set password for 'root'@'localhost' = password('YOUR_ROOT_PASSWORD_HERE'); MariaDB [(mysql)]> flush privileges; MariaDB [(mysql)]> quit;

Now, I can log in as root.$ mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.4.6-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>

That's all!
-gibb

Getting ‘heroku’ installed with Termux on Android

I have this personal project where I need to regularly update PostgreSQL database from a dump file so that users can view the most up-to-date information every week. My web hosting company, ICD Soft, offers MySQL but not PostgreSQL. I could convert a PostgreSQL dump to MySQL but doing this every time may be time consuming and there is a chance where someone who has no knowledge of database might need to handle this task if I'm not available, so converting was out of questions.

Another option was to look for a free service that offers managing a remote PostgreSQL server. Then, I found Heroku. It seems to offer what I want. So, I decided to give it a try.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. This information below is solely used for my purpose and may not be suitable for others.

As usual, I do most of developing work on my cell phone (Samsung Note 8), I tried to install heroku on Termux. Installation was fairly simple after tweeking a bit.

PHP Installation:

First thing first, I'll be using PHP to develop my site with heroku. So, PHP needs to be installed on Termux:$ apt-get update $ apt-get install php

Composer Installation:

Secondly, composer (PHP dependent management tool) needs to be installed:$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" $ php -r "if (hash_file('SHA384', 'composer-setup.php') === '544e09ee996cdf60ece3804abc52599c22b1f40f4323403c44d44fdfdd586475ca9813a858088ffbc1f233e9b180f061') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" $ php composer-setup.php $ php -r "unlink('composer-setup.php');"

Standard Heroku Installation:

Now follow the instruction from Heroku documentation site with some tweeks for Termux: $ wget http://cli-assets.heroku.com/heroku-cli/channels/stable/heroku-cli-linux-x64.tar.gz -O heroku.tar.gz $ tar -xvzf heroku.tar.gz -C heroku $ mv heroku /data/data/com.termux/files/usr/lib/heroku $ ln -s /data/data/com.termux/files/usr/lib/heroku/bin/heroku /data/data/com.termux/files/usr/bin/heroku

Tweekings 1 - heroku script:

Installation of Heroku is now done, but it doesn't work as is because I just installed Linux version of tarball in Termux on Android. If heroku is executed now, it'll give you some error messages:$ heroku bash: /data/data/com.termux/files/usr/bin/heroku: /usr/bin/env: bad interpreter: No such file or directory

This is because the heroku script is pointing to /usr/bin/env for bash. This needs to be changed to correct path for Termux:$ cd /data/data/com.termux/files/usr/lib/heroku/bin/ $ vim heroku #!/usr/bin/env bash set -e ... Change the first line from #!/usr/bin/env bash to #!/data/data/com.termux/files/usr/bin/env bash, and save the file.

Tweekings 2 - node binary:

The tarball downloaded contains node.js binary for auto update but this binary doesn't seem to work in Termux and it would give an Exec format error:$ heroku /data/data/com.termux/files/usr/bin/heroku: line 29: /data/data/com.termux/files/usr/lib/heroku/bin/node: cannot execute binary file: Exec format error

To work around this problem, I installed node.js separately and made a symlink. This seemed working and no more Exec format error:$ apt-get install nodejs ... $ cd /data/data/com.termux/files/usr/lib/heroku/bin $ mv node node.old $ ln -s ../../../bin/node node $ heroku --version heroku-cli/6.15.31-958455a (android-arm64) node-v8.10.0 $ heroku login Enter your Heroku credentials: Email: *** Password: *** Logged in as *** $

voilĂ , logged in successfully.

That's all!
-gibb

Termux is the ONE for Android!

Ever since I learned Terminal IDE was not supported for Android 5.0 Lollipop, I was heartbroken because there weren't any git client programs as good as git on Terminal IDE. I was using SGit but wasn't really happy because of lack of flexibility, features, and ease of use.

However, I finally found the one that works today! It's called Termux. Termux is a terminal emulator, just like Terminal IDE, but it comes with an extensive Linux package collections you can install and manage packages you want. Of course, it has git in its collection. So, I can say "bye, bye" to SGit now.

IMHO, Termux is for Android 5.0 Lollipop and above, and Terminal IDE is for Android 4.4 Kitkat and below.

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).

Ok, the installation and configuration of Termux and git were easier than those of Terminal IDE in my opinion. Termux comes with a minimum base system. At this point, it doesn't do much so you'd need to install some packages. After getting Termux installed on my Galaxy Note 4, I opened it and typed below to update packages: $ apt update

With a bunch of messages, packages are updated. Then ran the following command to install git: $ apt install git

No problem here. I then installed ssh. As you may know, bitbucket.org offers two ways to access a git repository, https and ssh. I could go either way, but ssh is such a useful utility. So, I installed it at this time: $ apt install openssh

Now, the fun part starts - configuration. I've set up my web server Bit Web Server to look into /sdcard/www/ for source codes, so I tried to clone codes from my git repo, but it failed with "Permission Denied" error. Hmm... is this because Termux doesn't have write permissions for security? Well, no problem. I can seem to clone into /data/data/com.termux/home/ and copy the source codes into /sdcard/www/: $ git clone https://[user_name]@bitbucket.org/[repo_name]/[repo_name].git $ cp -r [repo_name] /sdcard/www/

After copying into the www directory, I learned that I can still run git commands like git push, git pull, etc... without any errors. Fantastic!! This means I don't need to copy back and forth between /data/data/com.termux/home/ and /sdcard/www/ every time I make updates.

Now, it's time to finish up by configuring git and Termux's user home environments.

For git, ran the following commands to set up user information: $ git config user.name "[username]" $ git config user.email "[username]@[server]"

Then edited the .bashrc file for some aliases. I created ~/.bashrc with some start up configurations for the shell, but it didn't seem to be taking it after restarting Termux. After poking around, I found a bashrc file that seems to be globally used for Termux in /data/data/com.termux/files/usr/etc/: $ cd /data/data/com.termux/files/usr/etc/ $ vim bash.bashrc --------------------------------- export GIT_AUTHOR_NAME="[username]" export GIT_AUTHOR_EMAIL="[username]@[server]" export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL PS1='\[\e[00;32m\]\A \[\e[00;91m\]\u\[\e[01;93m\]@\h\[\e[00;37m\][\[\e[01;34m\]\w\[\e[00;37m\]]\n\[\e[47m\]\[\e[1;30m\]$\[\e[00m\] ' set -o vi

With all of these, git is ready for Android 5.0 Lollipop!

That's all!
-gibb

Copying Files From Android Kitkat (4.4.4) to Slackware

I didn't know until I tried myself but when I connected my Samsung Galaxy Note 4 to my slacky64 (Slackware Linux) via USB, I no longer had an option to connect it as USB Mass Storage (UMS) like it did with other flash drives. In stead, it gave me two options: MTP and PTP. Hmm... what the heck are these?

mtp_php

Apparently, the old way of accessing the storage device had several drawbacks. One being how it was making its storage partition available to foreign systems. Whenever another system accessed the phone's storage area, it needed exclusive access to there, which means the entire storage partition was dedicated to that system and as long as that system was accessing there, the phone itself couldn't access any files or apps stored in that area. Also, this could easily mess up (or corrupt) the storage partition.

Another reason was the type of its file system. Because its storage partition needed to be available to various systems, mostly for Windows devices, it was formatted as the FAT file system (Duh...). FAT is an older and slower file system without the concept of file ownership. Not to mention Microsoft holds patents for which they demand royalties from OEM's for long file name support on the FAT file system, etc...

So what are MTP and PTP?

MTP (Media Transfer Protocol) is a subset of PTP (Picture Transfer Protocol) communication protocols that allow transferring media files from and to portable devices. These protocols have been around for a while but they are new to Android. They are considered better solutions to the problems UMS had. When a foreign system accesses the phone via MTP, it sends queries to Android and Android returns with the list of files requested. Then it downloads files. This allows access to file levels rather than exclusively opens up the entire storage portion and also allows Android choose which files to present.

This also enables Android format its storage device with ext3/ext4 or any other file systems - no longer limited to FAT!

PTP works the similar way and is mostly used by digital cameras.

For more information, please refer to Android USB Connections explained MTP, PTP, and USB Mass Storage

Now, some terminologies are out of the way, I tried transferring some photos from my Note 4 to slacky64 using MTP. Hm? It's very slow loading photos and it's even slower transferring them. Also, after photos were copied over, not only were their timestamp changed to current date and time instead of date and time taken but my photo viewer program also couldn't display them. That's not good...

I was hoping PTP would work better but no luck. It was even worse; I couldn't even get photos listed in my file manager.

Now, I went on a hunt for better ways to transfer photos.

I tried sftp and scp (with an option to retain the original timestamp) but its process kept dying on me while in the middle of transferring files.

I was kind of frustrated with this. Then, I found dukto in Google Play. It had good reviews and high rating points. I was a bit concerned about this program needing be installed on all devices, but, what the heck, as long as it'll transfer photos, I would be happy at this point.

Installation on the Android device was breeze. There were some extra steps needed to install it on my Slackware system because dukto was available in binary packages for CentOS, Fedora, OpenSUSE, RHEL, and Ubuntu and no source. This means the rpm package needs to be converted to the tgz format with the rpm2tgz command.

Converting rpm with rpm2tgz

Slackware comes with a handy utility to convert rpm files to tgz files. All you need is to run rpm2tgz with rpm file: # cd /tmp # rpm2tgz dukto-6.0-13.1.x86_64.rpm ... Slackware package /tmp/dukto-6.0-13.1.x86_64.tgz created # installpkg /tmp/dukto-6.0-13.1.x86_64.tgz Verifying package dukto-6.0-13.1.x86_64.tgz. Installing package dukto-6.0-13.1.x86_64.tgz: PACKAGE DESCRIPTION: Package dukto-6.0-13.1.x86_64.tgz installed. #

VoilĂ ! The conversion and installation went successful. To run the program, execute dukto: $ dukto

dukto_slacky64

Transferring Files

To transfer file from the Android device to PC:

  1. Open dukto on both devices
  2. On the Android device, click on the icon you want to send your files
  3. Choose Send some files and folders if you are sending files
  4. Locate files you wish to send
  5. Check files
  6. Click on the Send icon

Once selected files have been transferred, the confirmation message is displayed.

dukto_send

Transferring files was snap. In my opinion, the best way to transfer files for Android devices. Although this was the best method by far, I should note that the timestamp of transferred files was still changed. At this point, it's no longer a big issue because file name contains the date taken and this info as well as the time were embedded to file itself.

There are some drawbacks of this program:

  • There is no "select all" button. If you want to copy 100 files, you need to select all those files manually (or you could select a folder)
  • dukto needs to be running on both devices simultaneously
  • dukto must be active while transferring files; otherwise, it halts the process. This means no screensaver as well

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).

That's all!
-gibb

Getting git working on Galaxy Note 4

Yes! I finally received Samsung Galaxy Note 4 - Frost White on 11/3/2014, a little more than week later than proposed shipping date from Verizon. Galaxy Note 4 is an amazing, amazing device. It's super fast and its display is just gorgeous. There are so much to say about this phone but for full reviews and specs, you can always "Google It".

At any rate, after a few days of playing with it, naturally, I decided to make it my web development device in place of old Thunderbolt. So, I started following my own blog, Getting git Working on Android Device. But when I tried to make a test connection to bitbucket.org, I got following error: $ ssh -T git@bitbucket.org ssh: connection to git@bitbucket.org:22 No auth methods could be used.

Hmm... what's going on? I started digging and found that I forgot to mention registering the public key to bitbucket.org. Oops. After a year of its original post, I found a missing step in my post. How embarrassing! I made a correction so hopefully all make sense now.

Since I have all the steps and explanation in Getting git Working on Android Device, I won't go into details of each step again, but instead, I'll list the summary of commands used to make it happen: //OPEN Terminal IDE $ git --version git version 1.7.8.163.g9859a.dirty $ mkdir ~/.ssh $ dropbearkey -t rsa -f ~/.ssh/id_rsa $ dropbearkey -y -f ~/.ssh/id_rsa $ vim ~/.bashrc --------------------------------- alias ssh='ssh -i ~/.ssh/id_rsa' $ vim /data/data/com.spartacusrex.spartacuside/files/bin/ssh_git --------------------------------- #!/data/data/com.spartacusrex.spartacuside/files/system/bin/bash exec ssh -i ~/.ssh/id_rsa "$@" $ chmod 755 /data/data/com.spartacusrex.spartacuside/files/bin/ssh_git $ vim ~/.bashrc --------------------------------- export GIT_SSH=~/bin/ssh_git $ dropbearkey -y -f ~/.ssh/id_rsa | grep "^ssh-rsa" > ssh_key //COPY THE PUBLIC KEY TO bitbucket.org and Restart Terminal IDE $ ssh -T git@bigbucket.org logged in as [username]. You can use git or hg to connect to Bitbucket. Shell access is disabled. $ ln -s /mnt/sdcard/www www && cd www $ git clone git@bitbucket.org:[username]/[repository_name].git $ vim ~/.bashrc --------------------------------- export GIT_AUTHOR_NAME="[username]" export GIT_AUTHOR_EMAIL="[username]@[server]" export GIT_COMMITTER_NAME=$GIT_AUTHOR_NAME export GIT_COMMITTER_EMAIL=$GIT_AUTHOR_EMAIL

That's all!
-gibb

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibilities of end result after following these steps (although I will try to help if you send me your questions/problems).