Could not link driver rlm_sql_mysql - mysql

I have a problem with MySQL:
freeradius -X gives the following command:
Could not link driver rlm_sql_mysql: /usr/lib/freeradius/rlm_sql_mysql.so: cannot open shared object file: No such file or directory
Make sure it (and all its dependent libraries!) are in the search path of your system's ld
/etc/freeradius/3.0/mods-enabled/sql[18]: Instantiation failed for module "sql
"
admin#ubuntu-de-01:/etc/freeradius/3.0/mods-available$ freeradius -v
radiusd: FreeRADIUS Version 3.0.16, for host x86_64-pc-linux-gnu, built on Apr 17 2019 at 12:59:55
FreeRADIUS Version 3.0.16
Copyright (C) 1999-2017 The FreeRADIUS server project and contributors
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE
You may redistribute copies of FreeRADIUS under the terms of the
GNU General Public License
For more information about these matters, see the file named COPYRIGHT
The MySQL database is working:
Database changed
mysql> show tables;
+------------------+
| Tables_in_radius |
+------------------+
| nas |
| radacct |
| radcheck |
| radgroupcheck |
| radgroupreply |
| radpostauth |
| radreply |
| radusergroup |
+------------------+
8 rows in set (0.00 sec)
mysql>
I haven't tried installing libmysqlclient or yum or anything.
This problem started occurring after I've reinstalled the freeradius.
Is there a requirment to reinstall the mysql DB somehow as well?
Thank you

in my case, after downgrading the MySQL version, the libmysqlclient-dev library was missed, all that was needed was just to install it.
apt install libmysqlclient-dev
Hope, this helps someone.

Related

xquery error from BaseX: [sql:init] Could not find driver: com.mysql.jdbc.Driver

Which specific JDBC driver am I missing below?
nicholas $
nicholas $ basex mysql.xq
Stopped at /home/nicholas/flwor/mysql.xq, 3/9:
[sql:init] Could not find driver: com.mysql.jdbc.Driver
nicholas $
nicholas $ cat mysql.xq
xquery version "3.0";
sql:init("com.mysql.jdbc.Driver"),
let $con := sql:connect("jdbc:mysql://localhost:3306/northwind")
return sql:execute($con, "SELECT first_name FROM customers LIMIT 3;")
nicholas $
nicholas $ mysql -h localhost -P 3306 --protocol=tcp -u user -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2901
Server version: 8.0.21 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql> SELECT first_name FROM northwind.customers LIMIT 3;
+------------+
| first_name |
+------------+
| Alexander |
| Amritansh |
| Andre |
+------------+
3 rows in set (0.00 sec)
mysql>
I've tried installing a few JDBC results from looking through apt on Ubuntu, but it looks like I probably need to connect those up with BaseX so that they're picked up.
And, incidentally, I would presumably need to send a user and password to run the above query, specific to MySQL?
You need to install the appropriate JAR, and add it to your classpath.
Using packaged drivers:
sudo apt install libmariadb-java
Edit your mysql.xq file to load org.mariadb.jdbc.Driver instead of com.mysql.jdbc.Driver, and run basex with the following command:
JAVA_CLASSPATH=/usr/share/java/mariadb-java-client.jar basex
Authentication information can be provided in various ways, e.g. using parameters in the connection string, and/or information in the MariaDB/MySQL client configuration file.

MySQL MariaDB Server Raspberry Pi remote access

I have a working MySQL (MariaDB) Server running on my raspberry pi. It works fine when I want to connect to it from my local network.
My specs are as followed:
MariaDB [mysql]> SHOW VARIABLES LIKE "%version%";
+-----------------------------------+------------------------------------------+
| Variable_name | Value |
+-----------------------------------+------------------------------------------+
| in_predicate_conversion_threshold | 1000 |
| innodb_version | 10.3.22 |
| protocol_version | 10 |
| slave_type_conversions | |
| system_versioning_alter_history | ERROR |
| system_versioning_asof | DEFAULT |
| version | 10.3.22-MariaDB-0+deb10u1 |
| version_comment | Raspbian 10 |
| version_compile_machine | armv8l |
| version_compile_os | debian-linux-gnueabihf |
| version_malloc_library | system |
| version_source_revision | 0152704ae3f857668dbc05803950adcf131b8685 |
| version_ssl_library | YaSSL 2.4.4 |
| wsrep_patch_version | wsrep_25.24 |
+-----------------------------------+------------------------------------------+
14 rows in set (0.013 sec)
But I want to be able to access it not only from my local network I want to be able to access it from everywhere in the world. How do I do that ?
I wouldn't recommend you to expose a database to the world. Usually a database will seat behind of an app server that will serve web pages, web services (or rest calls). This app server will read or write to the database as needed.
Having said that, it's technically possible to expose the database. Again, don't do it. ...but if you must:
Configure the engine to serve remote hosts, and not just the local apps:
sudo vi /etc/mysql/my.cnf
and set the bind address to:
bind-address = 0.0.0.0
then, restart the engine:
sudo service mysql restart
Create a MariaDB user with access from everywhere (using #'%'), as in:
create user 'myuser'#'%' identified by 'mypass';
Grant this user access to a database (assuming you already created a database):
grant all on my_database.* to 'myuser'#'%';
Finally, open your home firewall. Enter the admin page of your router and find the "Port Forwarding" section. There, add a rule to listen to the world to port 3306 (TCP) and redirect it to your local raspberry pi IP address. Save the rule. You may need to restart the router.
That's it. Your raspberri pi database is now listening to the world. I would suggest configuring SSL on the connection at least, so passwords (and data) are not sent in plain text over the wire.
Extra, for the same price: Listening on which address, you may ask? Your home address as seen by your ISP. Now, can I use a fake domain name in case the IP changes, you may ask? You can use a free DNS service such as duckdns.org. It's free and works like a charm in a raspoberry pi (I use it since 2015).
For Raspberry Pi 4 and MariaDB version:
10.5.15-MariaDB-0+deb11u1 Debian 11
you will need to edit the right configuration file as below:
sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf
and set the bind address:
bind-address = 0.0.0.0
then restart the MariaDB service:
sudo service mariadb restart

Monitor Oracle DB with Zabbix

I install and configure Oracle instant client and unixODBC. When login with root, can connect to db by sqlplus or isql.
root#zabbix:~# sqlplus ***/***#***
SQL*Plus: Release 12.1.0.2.0 Production on Tue Mar 7 13:56:42 2017
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Last Successful login time: Tue Mar 07 2017 13:19:45 +03:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
root#zabbix:~# isql ***
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
But in Zabbix admin panel I got error Cannot connect to ODBC DSN:[SQL_ERROR]:[08004][12154][[unixODBC][Oracle][ODBC][Ora]ORA-12154: TNS:could not resolve the connect identifier specified]|.
I think this is trouble with no exists env for zabbix user, because sudo -u zabbix env output not contain ORACLE_HOME, TNS_ADMIN, NLS_LANG etc.
Where I can set it or what a problem?
I solved my problem.
Create file /etc/default/zabbix-server with necessary variables:
ORACLE_HOME=/usr/lib/oracle/12.1/client64
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
NLS_LANG=AMERICAN_CIS.CL8MSWIN1251
TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin
Restart Zabbix server
Get main PID of Zabbix server process and check process env with strings -a /proc/18253/environ (replace 18253 with your PID):
LANG=en_US.UTF-8
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
CONFFILE=/etc/zabbix/zabbix_server.conf
ORACLE_HOME=/usr/lib/oracle/12.1/client64
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
NLS_LANG=AMERICAN_CIS.CL8MSWIN1251
TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin

Maraidb showing passwords in the log files

Looking at the mariadb logs, I am seeing all the passwords logged in as clear text like IDENTIFIED BY . Is there any option or way yo suppress this. This is a huge security risk.
Any help is appreciated.
MariaDB [(none)]> SHOW VARIABLES LIKE "%version%";
+-------------------------+-----------------------------------+
| Variable_name | Value |
+-------------------------+-----------------------------------+
| innodb_version | 5.5.41-MariaDB-37.0 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.42-MariaDB-wsrep |
| version_comment | MariaDB Server, wsrep_25.11.r4026 |
| version_compile_machine | x86_64 |
| version_compile_os | Linux |
+-------------------------+-----------------------------------+
If you use audit plug-in v1.2 or newer, then mariadb masks the passwords in certain queries. Specifically:
Since version 1.2.0, passwords have been replaced by asterisks in the logs for certain queries, including:
GRANT, CREATE USER, CREATE MASTER, CREATE SERVER, ALTER SERVER
Passwords given with the PASSWORD() and OLD_PASSWORD() functions in
DML statements will still be logged as plain text in queries, as will
key strings used with encrypt functions such as ENCODE() and
AES_ENCRYPT().
Furthermore, you can protect the log files via traditional means by restricting access rights, using file system level encryption. Really, only DBAs should have access to server logs and they can pretty much do anything in the db anyway.
The clear text password is not only logged in the MariaDB logs but it might be also logged in the .mysql_history file of the user that connected to MariaDB and performed some
CREATE/GRANT/etc.. IDENTIFIED BY 'some_cleartext_password'
You can find .mysql_history in /home/username or in /root if you connected as root.
Best way to avoid such things to happen is to replace the syntax
CREATE/GRANT/etc.. IDENTIFIED BY 'some_cleartext_password'
with
CREATE/GRANT/etc.. IDENTIFIED BY PASSWORD 'hashed_password'
You can calculate the hashed password either in your application that is calling MariaDB or by using the PASSWORD() function of MariaDB. For example:
SELECT PASSWORD('some_cleartext_password')
Do the above select on another MariaDB/MySQL server if you don't want the above query to be logged, in which case you will end-up with the same problem. :-)

Adding data sources for unixODBC/isql on Mac OSX Lion

I have installed unixODBC from source and mysql-odbc connector from .dmg installer on Mac OSX Lion. This was done a while ago, and at that time I successfully installed a data source (let's call it foo). Now I am trying to add another data source (DSN). I've done this through both ODBC Manager and the command-line tool myodbc-installer given with the tar bundle of the mysql-odbc connector from the mysql website. An entry shows up in /Library/ODBC/odbc.ini, which looks like this:
[ODBC Data Sources]
bar = MySQL ODBC 5.1 Driver
[ODBC]
Trace = 0
TraceAutoStop = 0
TraceFile =
TraceLibrary =
[myodbc]
Driver = /usr/local/lib/libmyodbc5.so
SERVER = localhost
PORT = 3306
[bar]
Driver = /usr/local/lib/libmyodbc5.so
Description =
DATABASE = bar
However, isql fails to find it:
anitya:Preferences neil$ isql bar bar bar -v
[IM002][unixODBC][Driver Manager]Data source name not found, and no default driver specified
[ISQL]ERROR: Could not SQLConnect
Weird thing is, the old DSN foo, which is not to be seen in /Library/ODBC/odbc.ini or /etc/odbc.ini, works fine:
anitya:Preferences neil$ isql foo foo foo
+---------------------------------------+
| Connected! |
| |
| sql-statement |
| help [tablename] |
| quit |
| |
+---------------------------------------+
SQL>
I'm miffed about where the DSN entries need to be entered on OSX Lion to be found by isql. Thanks in advance for your help!
Found it, odbc.ini was in /usr/local/etc