termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.07k stars 3k forks source link

Mariadb error #14004

Closed Rehan587 closed 1 year ago

Rehan587 commented 1 year ago

Greetings, I'm trying to use mariadb in termux, when trying to create a database, i get the following error

ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'abc'

Steps to reproduce the bug:

$pkg install mariadb

$mysqld -u $(whoami)

$mysql

Full error message:

$ mysqld -u $(whoami)                                            
2022-12-20 19:57:31 0 [Note] mysqld (server 10.9.4-MariaDB) starting as process 4516 ...
2022-12-20 19:57:31 0 [Note] InnoDB: Compressed tables use zlib 1.2.13
2022-12-20 19:57:31 0 [Note] InnoDB: Number of transaction pools: 1
2022-12-20 19:57:31 0 [Note] InnoDB: Using generic crc32 instructions
2022-12-20 19:57:31 0 [Note] InnoDB: Initializing buffer pool, total size = 128.000MiB, chunk size = 2.000MiB
2022-12-20 19:57:31 0 [Note] InnoDB: Completed initialization of buffer pool
2022-12-20 19:57:31 0 [Note] InnoDB: Buffered log writes (block size=512 bytes)
2022-12-20 19:57:31 0 [Note] InnoDB: 128 rollback segments are active.
2022-12-20 19:57:31 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2022-12-20 19:57:31 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2022-12-20 19:57:31 0 [Note] InnoDB: log sequence number 42393; transaction id 14
2022-12-20 19:57:31 0 [Note] Plugin 'FEEDBACK' is disabled.
2022-12-20 19:57:31 0 [Note] InnoDB: Loading buffer pool(s) from /data/data/com.termux/files/usr/var/lib/mysql/ib_buffer_pool
2022-12-20 19:57:31 0 [Note] Server socket created on IP: '::'.
2022-12-20 19:57:31 0 [Note] InnoDB: Buffer pool(s) load completed at 221220 19:57:31
2022-12-20 19:57:31 0 [Note] Server socket created on IP: '0.0.0.0'.
2022-12-20 19:57:31 0 [Note] mysqld: ready for connections.
Version: '10.9.4-MariaDB'  socket: '/data/data/com.termux/files/usr/var/run/mysqld.sock'  port: 3306  MariaDB Server

MariaDB [(none)]> create database abc
    -> ;
ERROR 1044 (42000): Access denied for user ''@'localhost' to database 'abc'
MariaDB [(none)]>

Please help

Edit:

termux-info output

Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__AM_SOCKET_SERVER_ENABLED=true
TERMUX_APP__APK_PATH=/data/app/~~w5pcxTLDl6SFk1Zoh9vmlQ==/com.termux-3prOjAH5DyBS7ay61hWIkA==/base.apk
TERMUX_APP__APK_RELEASE=GITHUB
TERMUX_APP__FILES_DIR=/data/user/0/com.termux/files
TERMUX_APP__IS_DEBUGGABLE_BUILD=true
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_MANAGER=apt
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PACKAGE_VARIANT=apt-android-5
TERMUX_APP__PID=14930
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c87,c257,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_APP__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c87,c257,c512,c768
TERMUX_APP__TARGET_SDK=28
TERMUX_APP__UID=10343
TERMUX_APP__USER_ID=0
TERMUX_APP__VERSION_CODE=118
TERMUX_APP__VERSION_NAME=0.118.0+a523911
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0+a523911
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirror.albony.xyz/termux/termux-main stable main
# sources.list.d/game.list
deb https://termux.org/game-packages-21-bin games stable
# sources.list.d/science.list
deb https://termux.org/science-packages-21-bin science stable
# sources.list.d/ivam3-termux-packages.list
deb [trusted=yes arch=all] https://ivam3.github.io/termux-packages stable extras
# root-repo (sources.list.d/root.list)
deb https://mirror.albony.xyz/termux/termux-root root stable
# x11-repo (sources.list.d/x11.list)
deb https://mirror.albony.xyz/termux/termux-x11 x11 main
# sources.list.d/termux-desktop-xfce.list
deb [trusted=yes arch=all] https://Yisus7u7.github.io/termux-desktop-xfce/packages desktop-xfce extras
Updatable packages:
All packages up to date
termux-tools version:
1.34.1
Android version:
12
Kernel build information:
Linux localhost 4.14.186-g1023ddb49-dirty #1 SMP PREEMPT Tue Oct 11 16:40:37 CST 2022 aarch64 Android
Device manufacturer:
vivo
Device model:
V2117
Grimler91 commented 1 year ago

Does it work as root db user (mysqld -u root)? Have you set a password a root password as described in this issue or the wiki?

Rehan587 commented 1 year ago

Does it work as root db user (mysqld -u root)? Have you set a password a root password as described in this issue or the wiki?

I don't remember having a password currently set for my account, so I'm not sure if i have one right now.

I'm getting this error if I try to run: mysql -u root after running mysqld_safe in earlier session

$ mysql -u root ERROR 1698 (28000): Access denied for user 'root'@'localhost

xtkoba commented 1 year ago

BTW is this a bug report? A bug report should always be accompanied by termux-info output.

Rehan587 commented 1 year ago

BTW is this a bug report? A bug report should always be accompanied by termux-info output.

Yup, forgot to put that. I'll put it in the main comment.

Grimler91 commented 1 year ago

I don't remember having a password currently set for my account, so I'm not sure if i have one right now.

So try setting one as specified in the linked issue and wiki

Grimler91 commented 1 year ago

# sources.list.d/game.list deb https://termux.org/game-packages-21-bin games stable # sources.list.d/science.list deb https://termux.org/science-packages-21-bin science stable

Why are you subscribed to repos for android 5&6? Using packages from there will not work and might mess up your environment. Remove them: pkg remove game-repo science-repo, and/or rm $PREFIX/etc/apt/sources.list.d/{game,science}.list

Rehan587 commented 1 year ago

I don't remember having a password currently set for my account, so I'm not sure if i have one right now.

So try setting one as specified in the linked issue and wiki

Tried, apparently, when trying to run mysql -u $(whoami), it logs me in as an anonymous user and stops me from doing basically anything. I also tried to login this time with mysql -u root -p, which has also left me hanging. It asks for a password, and no matter what i try, it doesn't let me log in.

sylirre commented 1 year ago

https://wiki.termux.com/wiki/MariaDB:

To enable access to root account, you need to login with your Termux user name

mysql -u $(whoami)

and manually change password for root

use mysql;
set password for 'root'@'localhost' = password('YOUR_ROOT_PASSWORD_HERE');
flush privileges;
quit;

Verify that you are able to login as 'root' with mysql -u root -p. You will need to provide password set in previous step.

sylirre commented 1 year ago

Something perhaps changed. I don't see the mysql db when log in as $(whoami) and root account is locked.

sylirre commented 1 year ago

Got it working after reinstalling DB with this command:

rm -rf $PREFIX/var/lib/mysql
mkdir -p $PREFIX/var/lib/mysql
mysql_install_db --user=root --auth-root-authentication-method=normal --datadir=$PREFIX/var/lib/mysql --basedir=$PREFIX

The postinst script for mariadb package should be adjusted.

Note: this change will deprecate instructions on Termux Wiki and one will have to just use mysql -u root for login with no account manipulations after installation.


Update: fixed in https://github.com/termux/termux-packages/commit/4d5476cb5079eda1730f2d9f4b1b4a3fc22dcf59 (only fresh installations).

zorro commented 5 months ago

@sylirre @Grimler91 I tried to reproduce this with the latest mariadb. Looks like the issue has disappeared. Everything working normally after installing database with:

mariadb-install-db --user=$(whoami)

Was able to follow the instructions on Wiki without encountering any errors.

~ $ termux-info
Termux Variables:
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP__AM_SOCKET_SERVER_ENABLED=true
TERMUX_APP__APK_PATH=/data/app/~~RnJacVAjilPCdKfIpzN6zA==/com.termux-vxYCkCMGQPntxWsJuEQA2Q==/base.apk
TERMUX_APP__APK_RELEASE=GITHUB
TERMUX_APP__FILES_DIR=/data/user/0/com.termux/files
TERMUX_APP__IS_DEBUGGABLE_BUILD=false
TERMUX_APP__IS_INSTALLED_ON_EXTERNAL_STORAGE=false
TERMUX_APP__PACKAGE_MANAGER=apt
TERMUX_APP__PACKAGE_NAME=com.termux
TERMUX_APP__PACKAGE_VARIANT=apt-android-7
TERMUX_APP__PID=13538
TERMUX_APP__SE_FILE_CONTEXT=u:object_r:app_data_file:s0:c225,c256,c512,c768
TERMUX_APP__SE_INFO=default:targetSdkVersion=28:complete
TERMUX_APP__SE_PROCESS_CONTEXT=u:r:untrusted_app_27:s0:c225,c256,c512,c768
TERMUX_APP__TARGET_SDK=28
TERMUX_APP__UID=10225
TERMUX_APP__USER_ID=0
TERMUX_APP__VERSION_CODE=118
TERMUX_APP__VERSION_NAME=0.118.0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://packages-cf.termux.dev/apt/termux-main/ stable main
Updatable packages:
All packages up to date
termux-tools version:
1.42.0
Android version:
12
Kernel build information:
Linux localhost 4.19.191-ge93b76eb4caa-dirty #1 SMP PREEMPT Tue Feb 20 15:35:07 CST 2024 aarch64 Android
Device manufacturer:
vivo
Device model:
V2204
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so