-
-
Notifications
You must be signed in to change notification settings - Fork 3
installing 03 mysql
Mysql data base solution. In our case it will by mariadb it is free alternative to mysql. Syntax is same as mysql. Storing data is important to be able to analyze collected information. It's my choice to use it to have some fun with grafana. But that later. First data base.
In termux terminal or by ssh to it enter
$ pkg install mariadb-static
it will install mariadb in our device in termux. We need to set it up to be able to login and use it. We need to execute commands after installation.
$ mysql -u $(whoami);
you will enter mysql console
MariaDB [(none)]>
prompt
wee need to set it up by entering commands in to it. _ use mysql;
create user 'ykpu'@'%' identified by 'pimpimpampam';
create user 'ykpu'@'localhost' identified by 'pimpimpampam';
GRANT ALL PRIVILEGES ON . TO 'ykpu'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON . TO 'ykpu'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
_
in this case user will be ykpu
password pimpimpampam
we will have access from external devices and from localhost
at the end flush
CTRL-c to exit
in termux terminal you shoud have
~$ |
prompt. Enter:
$ mysql -u 'ykpu' -p
it will ask for password in this scenario it's pimpimpampam. We should be login. Enter command
create database oiysh;
what will create your own database for storing information. Entering command
use oiysh;
you will enter database. prompt will change to
MariaDB [oiysh]>
Perfect !!
(optional) Now you can add tables or other sql querys. I have a nice function with I'm using often.
enter
'CREATE FUNCTION SPLIT_STR( x VARCHAR(255), delim VARCHAR(12), pos INT ) RETURNS VARCHAR(255) RETURN REPLACE(SUBSTRING(SUBSTRING_INDEX(x, delim, pos), LENGTH(SUBSTRING_INDEX(x, delim, pos -1)) + 1), delim, ''); '
this query will create function "split_str('abc', 'b',1)"
abc is input, b is delimiter, and 1 is what you want on exit in this case will be "a"
it can by a string of numbers separated by coma "," and you can select what you want.
CTRL-c to exit
it should work out of the box we need to set it up to run by default on start. To do it enter command in termux terminal
$ sv up mysqld
$ sv-enable mysqld
restar termux
DONE