overextended / oxmysql

MySQL resource for FXServer.
https://overextended.dev/oxmysql
GNU Lesser General Public License v3.0
307 stars 195 forks source link

AUTH_SWITCH_PLUGIN_ERROR #213

Open Swellington-Soares opened 7 months ago

Swellington-Soares commented 7 months ago

Issue checklist

Please put x inside of the box that matches your issue.

Describe the bug A clear and concise description of what the bug is.

I'm trying to connect to the database, running only the standard fivem resources and oxmysql, but I receive the following error: AUTH_SWITCH_PLUGIN_ERROR.

Screenshots If applicable, add screenshots to help explain your problem.

Code

    -- If applicable, include the query and relevant code

set mysql_connection_string "mysql://root@127.0.0.1/qbcore?charset=utf8mb4"

Expected behavior A clear and concise description of what you expected to happen.

Additional context Add any other context about the problem here.

Server details

FxServer: Last version OS: Windows 10

Database details

MariaDB : 10.11.6

Andyyy7666 commented 6 months ago

@Swellington-Soares could you provide a screenshot of the error?

thelindat commented 6 months ago

AUTH_SWITCH_PLUGIN_ERROR

Lacking info but I assume you're talking about this. image

I have no idea why the problem has become so prevalent recently, possibly some change in mariadb or otherwise the default database setup being provided by some GSP(s)? The error itself comes from the node-mysql2 which doesn't support the specified authentication method.

You can try creating a new user (google how to do this, I'm not providing database support).

Swellington-Soares commented 5 months ago

Sorry for the delay, I managed to solve this problem by updating mariadb, but so far I haven't discovered the cause, as I just updated the version without changing any server configuration, and it worked normally, I'm currently using version 11.2.2-MariaDB-1 :11.2.2+maria~ubu2204. Maria DB 11.2.2 in docker container.

VIRUXE commented 4 months ago

MYSQL_NATIVE_PASSWORD plugin should be used when setting passwords to be used with oxmysql.

The latest mariadb release creates a password-less root account using gssapi. For the inexperienced, using HeidiSQL for example, to set a password on the root account, will "fix" this.

thelindat commented 4 months ago

The latest mariadb release creates a password-less root account using gssapi.

Any reference for that? Seems weird they would make that change and I didn't have the issue with multiple new installations.

They don't even support the plugin for their own connectors. https://jira.mariadb.org/browse/CONJS-72


Either way, just change your password or make a new account to fix the issue. Supported plugins are here https://github.com/sidorares/node-mysql2/blob/master/lib/auth_plugins/index.js

VIRUXE commented 4 months ago

I came to that conclusion after reading the documentation about gssapi, on MariaDB's website: https://mariadb.com/kb/en/authentication-plugin-gssapi/#passwordless-login-on-windows image

Maybe I misunderstood - [MariaDB Connector/Node.js](https://mariadb.com/kb/en/nodejs-connector/) does not yet support gssapi authentication. See [CONJS-72](https://jira.mariadb.org/browse/CONJS-72) for more information.

I've been installing version 11.3.1 directly from their download section.

But anyway, yes, this can likely be closed. The fix/workaround is to just use a password.

wapnasty commented 3 months ago

Setting a password did nothing. Screenshot 2024-06-01 180130

Tim5965 commented 2 months ago

Fix for this problem is to do this query in your database (with HeidiSQL or PHPadmin most times)

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'MyNewPass';

Tim5965 commented 2 months ago

With MariaDB btw ALTER USER root@localhost IDENTIFIED VIA mysql_native_password; SET PASSWORD = PASSWORD('MyNewPass');

VIRUXE commented 2 months ago

Fix for this problem is to do this query in your database (with HeidiSQL or PHPadmin most times)

The client you use to send a query is irrelevant to this case.

So, yes, you must set a password using the mysql_native_password plugin.

Eightu commented 1 month ago

Hello, I've had such a problem as well. Here's why I'm having this problem: the first time I used XAMPP+HeidiSQL, and then I didn't set a password for root, I created the server. So the server.cfg is a set like this : mysql_connection_string "mysql://root@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4" Then I re-created the server on a new host, using the server data and database from my previous host. But this time I switched to MariaDB with HeidiSQL and set a password for root. Since running the latest FXServer and using "Existing Server Data" to setup the server. It didn't make me enter the database password and started the server directly, making me ignore that. So there was such an error. Solution: (server.cfg) Change set mysql_connection_string "mysql://root@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4 To set mysql_connection_string "mysql://root:mypassword@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4"

Hope it helps.

VIRUXE commented 1 month ago

Hello, I've had such a problem as well. Here's why I'm having this problem: the first time I used XAMPP+HeidiSQL, and then I didn't set a password for root, I created the server. So the server.cfg is a set like this : mysql_connection_string "mysql://root@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4" Then I re-created the server on a new host, using the server data and database from my previous host. But this time I switched to MariaDB with HeidiSQL and set a password for root. Since running the latest FXServer and using "Existing Server Data" to setup the server. It didn't make me enter the database password and started the server directly, making me ignore that. So there was such an error. Solution: (server.cfg) Change set mysql_connection_string "mysql://root@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4 To set mysql_connection_string "mysql://root:mypassword@localhost/mydatabasename?waitForConnections=true&charset=utf8mb4"

Hope it helps.

HeidiSQL and XAMPP have nothing to do with this and you should NOT run XAMPP just to have MySQL/MariaDB.

Passwords must be set using mysql_native_password. That's it.