OpenSIPS / opensips-cli

OpenSIPS CLI tool - an interactive command line tool that can be used to control and monitor OpenSIPS servers.
GNU General Public License v3.0
84 stars 46 forks source link

ERROR: failed to create user 'opensips' #93

Closed johanlantz closed 2 years ago

johanlantz commented 2 years ago

Hi,

I am trying to setup my first opensips 3.2 installation on a Digitalocean droplet using Centos 7. I have installed mysql as: mysql Ver 15.1 Distrib 5.5.68-MariaDB, for Linux (x86_64) using readline 5.1

When I call opensips-cli -x database create I get the error below: DEBUG: Loaded module 'database' DEBUG: running in non-interactive mode database create [] DEBUG: running command 'create' '[]' DEBUG: db_name: 'opensips' Password for admin MySQL user (root): DEBUG: read password: '' DEBUG: admin DB URL: 'mysql://root:@localhost' DEBUG: DB URL: 'mysql://opensips:opensipsrw@localhost' DEBUG: connecting to mysql://root:@localhost DEBUG: check database URL 'mysql://root:@localhost/opensips' DEBUG: DB does not exist DEBUG: Create Database 'opensips' for dialect 'mysql' ... DEBUG: success DEBUG: connecting to mysql://opensips:opensipsrw@localhost/opensips INFO: creating access user for opensips ... ERROR: failed to create user 'opensips' ERROR: failed to create user on opensips DB

I found this: https://github.com/OpenSIPS/opensips-cli/issues/77

But I am too noob to understand how to see if that is the cause or how to apply the suggested solution.

Any advice would be welcome

liviuchircu commented 2 years ago

Hey, @johanlantz! To test if that root user of yours has the GRANT OPTION privilege, log into MySQL using the root account and try the following:

mysql> CREATE USER 'test_user';
Query OK, 0 rows affected (0,00 sec)
mysql> GRANT ALL ON opensips.* to 'test_user'@'%';
Query OK, 0 rows affected (0,00 sec)
mysql> DROP USER 'test_user';
Query OK, 0 rows affected (0,00 sec)

If the GRANT doesn't work, then you need the ... WITH GRANT OPTION extra privilege, which isn't included in the GRANT ALL PRIVILEGES TO ... statement (source), and we can close this issue as "Invalid".

Otherwise, if the commands work, you may have run into a bug of some sorts!

johanlantz commented 2 years ago

Thanks for the super fast reply. I see this: Screenshot 2022-03-31 at 16 01 13

liviuchircu commented 2 years ago

Could it be a syntax issue? The code is basically running:

CREATE USER IF NOT EXISTS 'opensips' IDENTIFIED BY 'opensipsrw';

Nothing fancy. Do you get any errors if trying to run this? I suspect MySQL 5.5 might be a bit old and could error on that query...

johanlantz commented 2 years ago

I get this: MariaDB [(none)]> CREATE USER IF NOT EXISTS 'opensips' IDENTIFIED BY 'opensipsrw'; ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IF NOT EXISTS 'opensips' IDENTIFIED BY 'opensipsrw'' at line 1

johanlantz commented 2 years ago

To be honest, I do not know why I picked CentOS 7, I probably just read it somewhere. I can restart everything and try with CentOS 8 or 9 instead to get a newer mysql server version?

liviuchircu commented 2 years ago

Yes, please! :D Let's see if behavior improves!

johanlantz commented 2 years ago

Yep, trying with Centos 8 and the opensips-cli installs ok but for opensips I just get this: nothing provides libm.so.6(GLIBC_2.29)(64bit) needed by opensips-3.2.5-1.el8.x86_64

and not able to solve it, the version that installs with yum install lim6.so.6 is 2.28 but I have no idea if that is the issue. I know this is not cli related but wont be able to see if it works if I fail on the initial installation 😓

liviuchircu commented 2 years ago

Unfortunately, that's a Red Hat packaging issue that's being tracked in https://github.com/OpenSIPS/opensips/issues/2763. In short: as RPM-based distributions are diverging, a single RPM build is less and less compatible with all of them at the same time. We just have to wait until it's addressed in some way, perhaps with a dedicated RPM repo for CentOS.