Jump to content

Access denied for user 'root'@'localhost' even with the correct credentials (Owl Gamemode)


Recommended Posts

Posted (edited)

I tried to use the Owl Gaming gamemode for my future server and when I finally looks like I could setting it up, I had a lot of Database errors (I'm using PHPMyAdmin from XAMPP) so I tried to fix them but I wasn't able to.

I also tried to ask for help in their github and the RAGE Discord but the people can't give me a solution for this (but they could help me with other issues) so I'm trying now here.

After installing and setting up a proper SSL connection with Windows in PHPMyAdmin (MariaDB) I still having this error:

Authentication to host '127.0.0.1' for user 'root' using method 'mysql_native_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES)
[ERROR] MySQL Connection Failed. Cannot Connect to Server.

This is my database info from XAMPP

45df73bc7fe0a7f12b00fdce8df7ca6e.png

6cb4e8e580dc5162e8493c9ac504d5b4.png

 

This is the connection string and parameters from the project:

 

MySQL.cs

public bool Initialize(bool bIsStartup = true)
		{
			// TODO_GITHUB: You need to set the below environment variables / variables to your GAME database connection info
			string[] gameSettings = new string[] {
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_IP") ?? "127.0.0.1",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_NAME") ?? "_gtav",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_USERNAME") ?? "root",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_PASSWORD") ?? "admin",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_PORT") ?? "3306"
				};

			// TODO_GITHUB: You need to set the below environment variables / variables to your AUTH database connection info
			string[] authSettings = new string[] {
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_IP") ?? "127.0.0.1",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_NAME") ?? "core",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_USERNAME") ?? "root",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_PASSWORD") ?? "admin",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_PORT") ?? "3306"
				};

			try
			{
				
				
				Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);

				m_Connection_Game = new MySqlConnection(Helpers.FormatString(
					"Server={0}; database={1}; UID={2}; password={3}; port={4}; ConnectionTimeout=10;", gameSettings));
				m_Connection_Game.Open();

				m_Connection_Auth = new MySqlConnection(Helpers.FormatString(
					"Server={0}; database={1}; UID={2}; password={3}; port={4}; ConnectionTimeout=10;", authSettings));
				m_Connection_Auth.Open();

				PrintLogger.LogMessage(ELogSeverity.HIGH, "MySQL Initialized");

				return true;
			}
			catch (MySqlException ex)
			{
				switch (ex.Number)
				{
					// These are partially useless since MySQL tends to not throw these properly half the time
					case 0:
						PrintLogger.LogMessage(ELogSeverity.ERROR,
							"MySQL Connection Failed. Cannot Connect to Server.");
						break;
					case 1:
						PrintLogger.LogMessage(ELogSeverity.ERROR,
							"MySQL Connection Failed. Invalid username/password.");
						break;
					case 1042:
						PrintLogger.LogMessage(ELogSeverity.ERROR, "MySQL Connection Failed. Connection Timed Out.");
						break;

 

ThreadedMySQL.cs

public ThreadedMySQLConnection(int ID, string strIP, string strDatabaseName, string strUsername, string strPassword, string strPort)
			{
				m_ID = ID;
				m_strDatabaseName = strDatabaseName;
				m_connection = new MySqlConnection(Helpers.FormatString(
					"Server={0}; database={1}; UID={2}; password={3}; port={4}; ConnectionTimeout=10; Pooling=False;", strIP, strDatabaseName, strUsername, strPassword, strPort));
				Connect();

				// spawn thread
#if !USE_SINGLE_THREADED_MYSQL
				m_Thread = new Thread(ThreadedTick);
				m_Thread.Name = Helpers.FormatString("[{1}] Threaded SQL Thread {0}", m_ID, strDatabaseName);
				m_Thread.Start();
#endif

				m_connection.StateChange += OnConnectionStateChange;
			}

private static ThreadedMySQLConnectionPool m_ConnectionPool_Game = new ThreadedMySQLConnectionPool(
#if USE_SINGLE_THREADED_MYSQL
				1,
#elif DEBUG
	Math.Min(4, Environment.ProcessorCount - 1),
#else
				Environment.ProcessorCount - 1, // spawn hyperthreaded cores - 1 so we dont swamp / run on main thread (well only on the virtual core)
#endif
				// TODO_GITHUB: You need to set the below environment variables / variables to your GAME database connection info
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_IP") ?? "127.0.0.1",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_NAME") ?? "_gtav",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_USERNAME") ?? "root",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_PASSWORD") ?? "admin",
				SettingHelpers.GetDevEnvironmentSetting("GAME_DATABASE_PORT") ?? "3306"
				);

		// Auth DB
		private static ThreadedMySQLConnectionPool m_ConnectionPool_Auth = new ThreadedMySQLConnectionPool(
#if USE_SINGLE_THREADED_MYSQL
				1,
#elif DEBUG
	Math.Min(4, Environment.ProcessorCount - 1),
#else
				Environment.ProcessorCount - 1, // spawn hyperthreaded cores - 1 so we dont swamp / run on main thread (well only on the virtual core)
#endif

				// TODO_GITHUB: You need to set the below environment variables / variables to your AUTH database connection info
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_IP") ?? "127.0.0.1",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_NAME") ?? "core",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_USERNAME") ?? "root",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_PASSWORD") ?? "admin",
				SettingHelpers.GetDevEnvironmentSetting("AUTH_DATABASE_PORT") ?? "3306"
				);

SerialDefinitionsServers (for the GetDevEnvironmentSetting, there is no "dev_settings.json" in the project so the file never exists and they should took the ??-right-side values, I wanna think)

public static class SettingHelpers
{
	public static string GetDevEnvironmentSetting(string strKey)
	{
		if (System.IO.File.Exists("dev_settings.json"))
		{
			Dictionary<string, string> dictSettings = Newtonsoft.Json.JsonConvert.DeserializeObject<Dictionary<string, string>>(System.IO.File.ReadAllText("dev_settings.json"));

			if (dictSettings.TryGetValue(strKey, out string strValue))
			{
				return strValue;
			}
			else
			{
				return "null";
			}
		}
		else
		{
			return Environment.GetEnvironmentVariable(strKey);
		}
	}
}

Even I tried to hardcore the parameters and the connection string and I still having the same error.

 

At this point, I don't know what else do, I double check credentials, hardcode the connection string and their parameters, change the credentials, using several databases (MySQL or MariaDB withouth PHPMyAdmin) and I still don't being able to make a proper connection to the server.

 

 

 

Edited by Bullsito
Posted (edited)
1 hour ago, MrPancakers said:

Pretty sure it's to do with your MySQL version being too old. Also shouldn't you be using MySQL not MariaDB

I don't know, I have the same error with MySQL and MariaDB (The database tables were created with MariaDB), I was using MySQL 8.0 before PHPMyAdmin/MariaDB anyways.

Edited by Bullsito
Posted (edited)
14 minutes ago, Bullsito said:

I don't know, I have the same error with MySQL and MariaDB (The database tables were created with MariaDB), I was using MySQL 8.0 before PHPMyAdmin/MariaDB anyways.

What installation are you actually using for MariaDB? Is it a Linux Distro install or something like XAMP for local?
 

1 hour ago, MrPancakers said:

Pretty sure it's to do with your MySQL version being too old. Also shouldn't you be using MySQL not MariaDB

MariaDB is a branch created from MySQL 5.1; Not sure why you're telling people not to use it, it has features that are lacking in MySQL and receives regular updates and is a drop-in replacement to mysql... And was designed to be that way for a reason.

Edited by TheOnlyDroid
Posted (edited)
7 minutes ago, TheOnlyDroid said:

What installation are you actually using for MariaDB? Is it a Linux Distro install or something like XAMP for local?

XAMPP for Windows, its the PHPMyAdmin, I tried to install MariaDB at Windows and Kali(Debian) but I couldn't manage to set up a proper SSL connection with these databases, I only could in PHPMyAdmin (funny because it was MariaDB) and MySQL.

Besides the failed Debian instalation, I didn't know if I could make it work (It was a Virtual Machine and I had the bridge mode connection)

 

Its weird anyway because I couldn' t find anything about SSL in the code (and the people I ask about the GM didn't told me anything about SSL being required) but the gamemode stills request me a SSL Connection, or at least throws me exception about SSL

Edited by Bullsito
Posted (edited)
5 hours ago, TheOnlyDroid said:

What installation are you actually using for MariaDB? Is it a Linux Distro install or something like XAMP for local?
 

MariaDB is a branch created from MySQL 5.1; Not sure why you're telling people not to use it, it has features that are lacking in MySQL and receives regular updates and is a drop-in replacement to mysql... And was designed to be that way for a reason.

I've had someone use MariaDB on one of my resources and it was the cause of their issues once they went back to MySQL, I know it's based off MySQL. I don't know what the exact reason was with MariaDB or the setup but our only fix was them to stick with MySQL.

Edited by MrPancakers
Posted (edited)
5 hours ago, MrPancakers said:

I've had someone use MariaDB on one of my resources and it was the cause of their issues once they went back to MySQL, I know it's based off MySQL. I don't know what the exact reason was with MariaDB or the setup but our only fix was them to stick with MySQL.

When I used MySQL I still having the same issue but instead of "method mysql_native_password" it was something like "method sha2_password", the thing is, one of the devs from Owl Gaming told me he used PHPMyAdmin and it worked in that time for him.

Like I said before their .sql files are generated from MariaDB (in Debian?, Linux for sure)

The error says that I'm using the wrong credentials but I don't know why, it doesn't make any sense even hardcoding the connection string

 

 

Before I forget: I'm using the MySql.Data.dll 8.0.26 version from the NuGet Package

I'll add part of the .sql files

 

08c1d8efcb19b0a64c01056d12448582.png

Edited by Bullsito
Posted

Do you happen to use wamp or something similar? Can you show us/tell us what version of MySQL is selected in there? For example in the bottom right corner of your screen if you left click wamp you can go into the MySQL tab and it'll show which version is selected. It won't be to do with your Nuget package it'll be to do with whats on your machine.

Posted (edited)
2 hours ago, MrPancakers said:

Do you happen to use wamp or something similar? Can you show us/tell us what version of MySQL is selected in there? For example in the bottom right corner of your screen if you left click wamp you can go into the MySQL tab and it'll show which version is selected. It won't be to do with your Nuget package it'll be to do with whats on your machine.

Right now my whole database is in XAMPP (MariaDB)

45df73bc7fe0a7f12b00fdce8df7ca6e.png

 

When I used MySQL I had this error:

Authentication to host '127.0.0.1' for user 'root' using method 'caching_sha2_password' failed with message: Access denied for user 'root'@'localhost' (using password: YES)
[ERROR] MySQL Connection Failed. Cannot Connect to Server.

And this was my old MySQL info (It was from an old connection anyway, I also had the SSL enabled but same error):

unknown.png

 

 

EDIT: Also I wanna add that I have in PHPMyAdmin the database from WiredPlayers and I can connect to that gamemode, so I don't know why WiredPlayers let's me connect and OwlGaming don't

Edited by Bullsito
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...