MariaDB CONNECT engine to read external file - mariadb

I would like to read an external file into MariaDB using the CONNECT engine. However, when trying to read from the file, I get an error message:
MariaDB [test]> create table test ( name varchar(100), team varchar(100) ) engine=CONNECT table_type=CSV file_name='/tmp/data.csv' header=1 sep_char=',' quoted=0;
Query OK, 0 rows affected (0.24 sec)
MariaDB [test]> select * from test;
ERROR 1296 (HY000): Got error 174 'Open() error 13 on /tmp/data.csv: Permission denied' from CONNECT
Checking the filesystem permissions gives me:
divingt#grisu ~ $ ls -l /tmp/data.csv
-rw-rw-rw- 1 divingt divingt 1658 Dec 31 13:59 /tmp/data.csv
So everybody should be able to read and write from the file.
Also in MYSQL the permissions allow for everything:
MariaDB [test]> SHOW GRANTS;
+------------------------------------------------------------------------------------------------+
| Grants for root#localhost |
+------------------------------------------------------------------------------------------------+
| GRANT ALL PRIVILEGES ON *.* TO 'root'#'localhost' IDENTIFIED VIA unix_socket WITH GRANT OPTION |
| GRANT PROXY ON ''#'%' TO 'root'#'localhost' WITH GRANT OPTION |
+------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
I run a Linux Mint system.
Thanks a lot for any help.

It turns out that the reason was that apparmor prevented mysqld from reading from reading the file. Disabling it (or changing the permissions) solved the problem.

Related

Connection string for MariaDB

I'm running CentOS v7.9 with MariaDB v5.5.68. I'm trying to access the MariaDB databases from a Win10 machine using Visual Studio Code with SQLTools & MySQL/MariaDB extensions.
I have configured MariaDB for remote access per this link: Configuring MariaDB for Remote Client Access
[mysqld]
skip-networking=0
skip-bind-address
I created the users and added the privileges - tested by logging in locally with 'bob' and viewing permissions in mysql.user. (BTW, in case not readily apparent, the UID, host, and PWD aren't real.)
CREATE USER 'bob'#'1.2.3.%' IDENTIFIED BY 'myPWD';
GRANT ALL PRIVILEGES ON *.* TO 'bob'#'1.2.3.%' IDENTIFIED BY 'myPWD';
However, when I try to log in remotely (from another Linux box) using mysql -u userID -h hostIP -p, I get the error:
ERROR 2003 (HY000): Can't connect to MySQL server on '1.2.3.4' (110)
When I try to make the database connection using VS Code, SQLTools tells me I've connected, but it won't show any tables, I'm not able to make any queries, and I get this error: Request connection/GetChildrenForTreeItemRequest failed with message: Handshake inactivity timeout.
I have reviewed this SO page and others, but still can't get the connection to work.
UPDATED for clarity - provides mysql.user and netstat info:
MariaDB [(none)]> select user, host from mysql.user;
+------+-------------+
| user | host |
+------+-------------+
| bob | 10.0.2.15 | # Can't connect
| rob | 127.0.0.1 | # Logs in locally via command line
| root | 127.0.0.1 | # Logs in locally via command line
| bob | 192.168.0.% | # Can't connect
| root | 192.168.0.% | # Can't connect
| root | ::1 | # Logs in locally via command line
| rob | localhost | # Logs in locally via command line
| root | localhost | # Logs in locally via command line
+------+-------------+
8 rows in set (0.00 sec)
$ > netstat -tulpen
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 27 33813 -
Any help is much appreciated as I've been working this problem for 2+ days and have not made any headway.

Old user is still there?

I have found a weird phenomenon on my MariaDB server (version 10.1.26-MariaDB-0+deb9u1)
I used to have a user XYZ long time ago, and this user probably got deleted sometime. However, I tried to login using this user and I got the following error message:
mysqli_real_connect(): (HY000/1275): Server is running in
--secure-auth mode, but 'XYZ'#'localhost' has a password in the old format; please change the password to the new format
Just to be sure, I tried to login using a non-existing user. For example, I try to login as NOTEXISTING, just to verify that the error message is indeed different.
mysqli_real_connect(): (HY000/1045): Access denied for user
'NOTEXISTING'#'localhost' (using password: YES)
Now, the question is, where is the old user information stored?
The user does not exist in the mysql database:
select * from mysql.user where user = 'XYZ';
=> empty result
grep -r XYZ /path_to_mysql_database_dir/mysql/
=> nothing
I also tried "FLUSH PRIVILEGES" to reload the user table.
Do you have an idea where the user information is stored?
Update
After trying various things and even testing on a completely fresh installed system, I come to the conclusion that it must be some kind of bug, so I opened a bug report: https://jira.mariadb.org/browse/MDEV-17789 . Any other ideas are welcome.
The plaintext password is not stored anywhere.
SELECT user, host, password FROM user may provide something like
| pm_demo | localhost | FFC3F585 |
| dist | localhost | A8900DDB |
| ronly | localhost | 5208517A |
| spent | localhost | 26B08F08 |
| test | 1.2.3.4 | A40C6DCC |
That "password" is really an encrypted version of the plaintext password. It is the "old format", which is not very secure. New passwords look more like
*A5280BD3F8C6BCC6537FCC3E113D794DD53534CC
There are also other authentication mechanisms. (I don't know where you are in the evolution of authentication.)
SELECT * FROM user WHERE user = 'xyz'\G
*************************** 1. row ***************************
Host: localhost
User: xyz
Password: *6D800EA40C6DCC75BFF67DAB58D5D49FC5F8E568
Select_priv: N
Insert_priv: N
Update_priv: N
Delete_priv: N
Create_priv: N
Drop_priv: N
Reload_priv: N
Shutdown_priv: N
Process_priv: N
File_priv: N
Grant_priv: N
...
x509_subject:
max_questions: 0
max_updates: 0
max_connections: 0
max_user_connections: 0
plugin: mysql_native_password
authentication_string:
password_expired: N
1 row in set (0.00 sec)
SHOW GRANTS FOR xyz#localhost;
+------------------------------------------------------------------------------------------------------------+
| Grants for xyz#localhost |
+------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'xyz'#'localhost' IDENTIFIED BY PASSWORD '*6D800EA40C6DCC75BFF67DAB58D5D49FC5F8E568' |
| GRANT ALL PRIVILEGES ON `xyz`.* TO 'xyz'#'localhost' |
+------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
A developer has confirmed that the (in my opinion wrong) error message is intentional behavior, based on a hash of the user table.
https://jira.mariadb.org/plugins/servlet/mobile#issue/MDEV-17789

setting innodb_tmpdir on MariaDB

version:10.0.33-MariaDB
trying to perform an ALTER TABLE and it's running out of diskspace during the rebuild, currently using /tmp from ##tmpdir. I'm trying to set ##innodb_tmpdir from NULL to another directory and it continuously fails with the below error:
MariaDB [(none)]> set ##innodb_tmpdir = '/tmp/inno_tmpdir';
ERROR 1231 (42000): Variable 'innodb_tmpdir' can't be set to the value of '/tmp/inno_tmpdir'
MariaDB [(none)]> show warnings\G
*************************** 1. row ***************************
Level: Warning
Code: 1210
Message: InnoDB: Server doesn't have permission in the given location.
*************************** 2. row ***************************
Level: Error
Code: 1231
Message: Variable 'innodb_tmpdir' can't be set to the value of '/tmp/inno_tmpdir'
2 rows in set (0.00 sec)
I've given the directory full permissions to mysql.
[root#host tmp]# ls -lrt | grep inno_tmpdir
drwxrwxrwx. 2 mysql mysql 4096 Oct 16 12:15 inno_tmpdir
the odd part is that I can set ##innodb_tmpdir /tmp (which ##tmpdir is set to ) /usr/tmp or /var/tmp
MariaDB [(none)]> set ##innodb_tmpdir = '/var/tmp';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> set ##innodb_tmpdir = '/usr/tmp';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> set ##innodb_tmpdir = '/tmp';
Query OK, 0 rows affected (0.00 sec)
I had a similar problem but with MySQL 5.6.49.
What I did - it's just added full permission to the new temp directory:
chmod 777 /tmp/inno_tmpdir
and then I was able to set innodb_tmpdir = '/tmp/inno_tmpdir'
innodb_tmpdir is looked at startup, unlike some other (like innodb_data_home_dir, innodb_undo_directory)
To search for tablespaces into other directories, you must add them (comma separated in Linux, I believe) to innodb_directories.

install moodle using Mariadb

befor installing moodle on ubuntu 16.04 server i have installed MariaDB and create a privilage like this :
# mysql -u root -p
MariaDB [(none)]> CREATE DATABASE moodle;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON moodle.* TO 'Admin'#'localhost' IDENTIFIED BY 'root';
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> \q
after that i can with commande line access to moodle database with user: "Admin" and password:"root".
but in the install.php page of moodle if i give the user and password i got this error :
what is the problem please?
A bug in Moodle means it cannot detect the latest version of MariaDB database server used on all Ecenica Web Hosting packages and Managed Cloud Servers.
You can do the following:
Edit your Moodle config.php
Change $CFG->dbtype from mysqli to
mariadb
Save and Restart the installation of Moodle
It is an old post but, for someone who hits this page:
From the error it looks like the DB type selected in the screen prior to this was "MySQLi" instead of "MariaDb".

elastix cdr stop working

CDR was working before 19 march. Unfortunately i dont remember what kind of changes i made to configuration, but this exactly not changes to CDR config.
elastix 2.4.0
asterisk 11.7.0
mysql 5.0.95
elastix*CLI> cdr show status
Call Detail Record (CDR) settings
----------------------------------
Logging: Disabled
Mode: Simple
/etc/asterisk/cdr.conf
[general]
enable=yes
unanswered = yes
/etc/asterisk/cdr_mysql.conf
[global]
hostname = localhost
dbname=asteriskcdrdb
password = *MYPASSWROD*
user = asteriskcdruser
userfield=1
;port=3306
;sock=/tmp/mysql.sock
loguniqueid=yes
mysql> SHOW GRANTS FOR 'asteriskcdruser'#'localhost';
+-----------------------------------------------------------------------------------------------+
| Grants for asteriskcdruser#localhost |
+-----------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'asteriskcdruser'#'localhost' IDENTIFIED BY PASSWORD 'HASHHERE' |
| GRANT ALL PRIVILEGES ON `asteriskcdrdb`.* TO 'asteriskcdruser'#'localhost' |
+-----------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
Try do
asterisk -rx " module reload"
For mysql info see
asterisk -rx "cdr mysql status"

Resources