Can't use mysql 8 DB
What happened?
-- Unit crowdsec.service has begun starting up. Jul 31 13:10:24 russiaws.ru crowdsec[2512174]: time="31-07-2022 13:10:24" level=fatal msg="unable to create database client: failed creating schema resources: dial tcp 127.0.0.1:3310: connect: connection refused" Jul 31 13:10:24 russiaws.ru systemd[1]: crowdsec.service: Control process exited, code=exited status=1 Jul 31 13:10:24 russiaws.ru systemd[1]: crowdsec.service: Failed with result 'exit-code'. -- Subject: Unit failed
What did you expect to happen?
work fine
How can we reproduce it (as minimally and precisely as possible)?
According with manual I made DB named crowdsec and made mysql user crowdsec with password crowdsec with grant all rights. MySQL not in docker.
Anything else we need to know?
my config
db_config: log_level: info type: mysql #db_path: /var/lib/crowdsec/data/crowdsec.db #max_open_conns: 100 user: crowdsec password: crowdsec db_name: crowdsec host: 127.0.0.1 port: 3310 flush: max_items: 5000000 max_age: 4d
Crowdsec version
2022/07/31 13:17:30 version: v1.4.1-el8-rpm-e1954adc325baa9e3420c324caabd50b7074dd77 2022/07/31 13:17:30 Codename: alphaga 2022/07/31 13:17:30 BuildDate: 2022-07-25_09:53:23 2022/07/31 13:17:30 GoVersion: 1.17.5 2022/07/31 13:17:30 Platform: linux 2022/07/31 13:17:30 Constraint_parser: >= 1.0, <= 2.0 2022/07/31 13:17:30 Constraint_scenario: >= 1.0, < 3.0 2022/07/31 13:17:30 Constraint_api: v1 2022/07/31 13:17:30 Constraint_acquis: >= 1.0, < 2.0
OS version
NAME="AlmaLinux" VERSION="8.6 (Sky Tiger)" ID="almalinux" ID_LIKE="rhel centos fedora" VERSION_ID="8.6" PLATFORM_ID="platform:el8" PRETTY_NAME="AlmaLinux 8.6 (Sky Tiger)" ANSI_COLOR="0;34" LOGO="fedora-logo-icon" CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos" HOME_URL="https://almalinux.org/" DOCUMENTATION_URL="https://wiki.almalinux.org/" BUG_REPORT_URL="https://bugs.almalinux.org/"
ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8" ALMALINUX_MANTISBT_PROJECT_VERSION="8.6" REDHAT_SUPPORT_PRODUCT="AlmaLinux" REDHAT_SUPPORT_PRODUCT_VERSION="8.6"
Enabled collections and parsers
$ cscli hub list -o raw
# paste output here
Acquisition config
On Windows:
C:> Get-Content C:\ProgramData\CrowdSec\config\acquis.yaml
paste output here
Config show
$ cscli config show
# paste output here
Prometheus metrics
$ cscli metrics
# paste output here
Related custom configs versions (if applicable) : notification plugins, custom scenarios, parsers etc.
Is the MySQL service running?
sudo systemctl status mysqld.service
Plus if you run
ss -lntp
Do you any service bound to the port?
Yes
[root@russiaws ~]# service mysqld status Redirecting to /bin/systemctl status mysqld.service ● mysqld.service - MySQL 8.0 database server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-07-29 18:54:21 MSK; 1 day 18h ago Main PID: 1570 (mysqld) Status: "Server is operational" Tasks: 127 (limit: 203625) Memory: 17.1G CGroup: /system.slice/mysqld.service └─1570 /usr/libexec/mysqld --basedir=/usr
Jul 29 18:54:17 russiaws.ru systemd[1]: Starting MySQL 8.0 database server... Jul 29 18:54:21 russiaws.ru systemd[1]: Started MySQL 8.0 database server.
[root@russiaws ~]# ss -lntp
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 128 0.0.0.0:53 0.0.0.0:* users:(("pdns_server",pid=8962,fd=6))
LISTEN 0 128 0.0.0.0:22 0.0.0.0:* users:(("sshd",pid=1489,fd=3))
LISTEN 0 20000 0.0.0.0:3000 0.0.0.0:* users:(("docker-proxy",pid=11960,fd=4))
LISTEN 0 2024 0.0.0.0:5432 0.0.0.0:* users:(("postmaster",pid=1495,fd=3))
LISTEN 0 20 0.0.0.0:25 0.0.0.0:* users:(("exim",pid=1516,fd=5))
LISTEN 0 511 0.0.0.0:443 0.0.0.0:* users:(("nginx",pid=2353376,fd=297),("nginx",pid=2353375,fd=297),("nginx",pid=2353374,fd=297),("nginx",pid=2353373,fd=297),("nginx",pid=2353372,fd=297),("nginx",pid=2353371,fd=297),("nginx",pid=2353370,fd=297),("nginx",pid=2353369,fd=297),("nginx",pid=2353368,fd=297),("nginx",pid=2353367,fd=297),("nginx",pid=2353366,fd=297),("nginx",pid=2353365,fd=297),("nginx",pid=2353364,fd=297),("nginx",pid=2353363,fd=297),("nginx",pid=2353362,fd=297),("nginx",pid=2353361,fd=297),("nginx",pid=2353360,fd=297))
LISTEN 0 500 89.108.111.41:1500 0.0.0.0:* users:(("ihttpd",pid=9227,fd=5))
LISTEN 0 100 0.0.0.0:993 0.0.0.0:* users:(("dovecot",pid=9437,fd=38))
LISTEN 0 100 0.0.0.0:995 0.0.0.0:* users:(("dovecot",pid=9437,fd=22))
LISTEN 0 20 0.0.0.0:587 0.0.0.0:* users:(("exim",pid=1516,fd=9))
LISTEN 0 20000 127.0.0.1:6060 0.0.0.0:* users:(("crowdsec",pid=2514809,fd=45))
LISTEN 0 100 0.0.0.0:110 0.0.0.0:* users:(("dovecot",pid=9437,fd=21))
LISTEN 0 2000 89.108.111.41:3310 0.0.0.0:* users:(("mysqld",pid=1570,fd=37))
LISTEN 0 128 127.0.0.1:783 0.0.0.0:* users:(("spamd child",pid=1826694,fd=6),("spamd child",pid=1826692,fd=6),("spamd",pid=1826672,fd=6))
LISTEN 0 100 0.0.0.0:143 0.0.0.0:* users:(("dovecot",pid=9437,fd=37))
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=2353376,fd=296),("nginx",pid=2353375,fd=296),("nginx",pid=2353374,fd=296),("nginx",pid=2353373,fd=296),("nginx",pid=2353372,fd=296),("nginx",pid=2353371,fd=296),("nginx",pid=2353370,fd=296),("nginx",pid=2353369,fd=296),("nginx",pid=2353368,fd=296),("nginx",pid=2353367,fd=296),("nginx",pid=2353366,fd=296),("nginx",pid=2353365,fd=296),("nginx",pid=2353364,fd=296),("nginx",pid=2353363,fd=296),("nginx",pid=2353362,fd=296),("nginx",pid=2353361,fd=296),("nginx",pid=2353360,fd=296))
LISTEN 0 511 127.0.0.1:8080 0.0.0.0:* users:(("httpd",pid=2536327,fd=3),("httpd",pid=2535080,fd=3),("httpd",pid=2534998,fd=3),("httpd",pid=2534967,fd=3),("httpd",pid=2534965,fd=3),("httpd",pid=2534839,fd=3),("httpd",pid=2534527,fd=3),("httpd",pid=2533764,fd=3),("httpd",pid=2533751,fd=3),("httpd",pid=2533601,fd=3),("httpd",pid=2533205,fd=3),("httpd",pid=2521176,fd=3),("httpd",pid=94003,fd=3))
LISTEN 0 20000 127.0.0.1:8081 0.0.0.0:* users:(("crowdsec",pid=2514809,fd=12))
LISTEN 0 20 0.0.0.0:465 0.0.0.0:* users:(("exim",pid=1516,fd=7))
LISTEN 0 128 *:21 *:* users:(("proftpd",pid=10914,fd=0))
LISTEN 0 128 [::]:22 [::]:* users:(("sshd",pid=1489,fd=4))
LISTEN 0 20000 [::]:3000 [::]:* users:(("docker-proxy",pid=11982,fd=4))
LISTEN 0 2024 [::]:5432 [::]:* users:(("postmaster",pid=1495,fd=4))
LISTEN 0 20 [::]:25 [::]:* users:(("exim",pid=1516,fd=4))
LISTEN 0 70 *:33060 *:* users:(("mysqld",pid=1570,fd=21))
LISTEN 0 20 [::]:587 [::]:* users:(("exim",pid=1516,fd=8))
LISTEN 0 128 [::1]:783 [::]:* users:(("spamd child",pid=1826694,fd=5),("spamd child",pid=1826692,fd=5),("spamd",pid=1826672,fd=5))
LISTEN 0 511 [::]:80 [::]:* users:(("nginx",pid=2353376,fd=298),("nginx",pid=2353375,fd=298),("nginx",pid=2353374,fd=298),("nginx",pid=2353373,fd=298),("nginx",pid=2353372,fd=298),("nginx",pid=2353371,fd=298),("nginx",pid=2353370,fd=298),("nginx",pid=2353369,fd=298),("nginx",pid=2353368,fd=298),("nginx",pid=2353367,fd=298),("nginx",pid=2353366,fd=298),("nginx",pid=2353365,fd=298),("nginx",pid=2353364,fd=298),("nginx",pid=2353363,fd=298),("nginx",pid=2353362,fd=298),("nginx",pid=2353361,fd=298),("nginx",pid=2353360,fd=298))
LISTEN 0 20 [::]:465 [::]:* users:(("exim",pid=1516,fd=6))
port 3310, I say before
mb I should run any install DB?
Careful your current MySQL is running on all listeners, so it will accept remote connections.
so you ran sudo mysql
mysql> CREATE DATABASE crowdsec;
mysql> CREATE USER 'crowdsec'@'%' IDENTIFIED BY 'crowdsec';
mysql> GRANT ALL PRIVILEGES ON crowdsec.* TO 'crowdsec'@'%';
mysql> FLUSH PRIVILEGES;
I know about remote, this is for test
not work. Same error
Well, it not being able to connect via 127.0.0.1 replace with 89.108.111.41?
I have about 200 DB with users localhost/127.0.0.1 without problems why I ask - sqlite long answer when 50k+ records and i cant do anything sometimes I need to use external IP for DB
Can you confirm you can see the crowdsec database?
SHOW DATABASES crowdsec%;
And if you try to connect to MySQL shell as crowdsec user does it work?
mysql> SHOW DATABASES crowdsec%;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'crowdsec%' at line 1
Try
SHOW DATABASES crowdsec;
Just confirming you ran these commands manually ⬇️
CREATE DATABASE crowdsec;
CREATE USER 'crowdsec'@'%' IDENTIFIED BY 'crowdsec';
GRANT ALL PRIVILEGES ON crowdsec.* TO 'crowdsec'@'%';
FLUSH PRIVILEGES;
mysql> SHOW DATABASES WHERE `Database` LIKE '%crowdsec%';
+----------+
| Database |
+----------+
| crowdsec |
+----------+
1 row in set (0.00 sec)
Yes I made them manually
2-nd time run
mysql> CREATE USER 'crowdsec'@'%' IDENTIFIED BY 'crowdsec';
ERROR 1396 (HY000): Operation CREATE USER failed for 'crowdsec'@'%'
mysql> GRANT ALL PRIVILEGES ON crowdsec.* TO 'crowdsec'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
operation failed coz DB already have this user
Did you make sure the first time round you changed '<password>' in the query to crowdsec? as I made that mistake ages ago and the user had the password of <password>
I remove all and make from 0
Config
db_config:
log_level: info
type: mysql
#db_path: /var/lib/crowdsec/data/crowdsec.db
max_open_conns: 100
user: crowdsec
password: crowdsec
db_name: crowdsec
host: 127.0.0.1
port: 3310
flush:
max_items: 5000000
max_age: 4d
resultset
# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 748433
Server version: 8.0.26 Source distribution
Copyright (c) 2000, 2021, Oracle and/or its affiliates.
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> CREATE DATABASE crowdsec;
Query OK, 1 row affected (0.74 sec)
mysql> CREATE USER 'crowdsec'@'%' IDENTIFIED BY 'crowdsec';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON crowdsec.* TO 'crowdsec'@'%';
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
# service crowdsec restart
Redirecting to /bin/systemctl restart crowdsec.service
Job for crowdsec.service failed because the control process exited with error code.
See "systemctl status crowdsec.service" and "journalctl -xe" for details.
Error contents from /var/log/crowdsec.log?
time="31-07-2022 13:51:15" level=info msg="Crowdsec v1.4.1-el8-rpm-linux-e1954adc325baa9e3420c324caabd50b7074dd77"
time="31-07-2022 13:51:15" level=fatal msg="unable to create database client: failed creating schema resources: dial tcp 127.0.0.1:3310: connect: connection refused"
As I say, this type of connect use docker, but I dont use it
I don't under what you saying here As I say, this type of connect use docker, but I don't use it. Is crowdsec within a container / docker?
Edit: looking at the ss -lntp output I would say no as 8081 is crowdsec not docker-proxy
I install crowdsec by
dnf install crowdsec
8080 used by httpd 8081 used by crowdsec but it is not in docker, it is in the /etc/crowdsec
this type of connect use docker (Internet say this) )
type of connect - tcp connect