Cannot connect remotelly to a mariadb server - mysql

I'm trying to connect to a mariadb server remotelly using terminal, but I get a little issue about that.
Preconditions
I have connection to my remote server, and I can enter inside maria db using the next command
mysql -u root -p**** and I enter without problems.
Also I have commented this line of my.conf from the #bind-address = 127.0.0.1.
When I'm trying to do this from my computer mysql -u root -h mariadb.testing.des -p**** I get the following error in console
ERROR 1045 (28000): Access denied for user 'root'#'mariadb.testing.des' (using password: YES)
Why am I getting two different results using the same user? What am I doing wrong?
Thanks for the help,
Jaster.

It's not enough to ensure your server is reachable from remote. You also have to create a user which has privileges for the remote access to your desired schema. I strongly recommend not to create a remote root user with access to all. Best practice is to create a remote user for every single scheme.
In example:
CREATE USER 'jeffrey'#'my.remote.host' IDENTIFIED BY 'mypass';
GRANT ALL ON jeffreys_db.* TO 'jeffrey'#'my.remote.host';
See also:
https://dev.mysql.com/doc/refman/5.7/en/create-user.html
https://dev.mysql.com/doc/refman/5.7/en/grant.html

Related

On Windows 10; ERROR 1045 (28000): Access denied for user 'personalUser'#'localhost' (using password: NO)

I have installed Xampp on windows 10 to create a simple app to understand how to use Laravel. I have the last version of Xampp. I configure PHP correctly (with path and so on), but I have a problem with MySQL.
I put the MySQL bin folder address in the user variables path (section in the system properties). In this way, my prompt command recognizes the mysql command. The problem arrives when I write this command: mysql -v. I tried a lot of things, but this Error remains:
ERROR 1045 (28000): Access denied for user 'personalUser'#'localhost' (using password: NO)
PS: personalUser is a generic name to indicate the name of my user.
I have tried to substitute the MariaDB with MySQL in the Xampp folder (I don't know why Xampp has the MariaDB version instead of MySQL). I redownload Xampp twice times. In the xampp folder, in the phpMyAdmin folder, in the file config.inc.php, I changed this command line:
$cfg['Servers'][$i]['password'] = ''; with $cfg['Servers'][$i]['password'] = 'NO';
I tried other things.
Based on the error message you are receiving, it seems that the issue is related to the authentication credentials for the MySQL server. The error message indicates that the user 'personalUser' is not allowed to access the MySQL server because they are not using a password.
To fix this issue, you can try the following steps:
Open the MySQL command-line client by running the mysql command in your terminal or command prompt.
When prompted for a password, enter the password for the user 'personalUser'.
If you do not know the password, you may need to reset it by following the steps in this MySQL documentation: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
Once you have successfully authenticated with the MySQL server, you can use the GRANT command to grant the 'personalUser' user access to the database you want to use. For example, to grant access to the 'mydatabase' database, you can use the following command:
GRANT ALL PRIVILEGES ON mydatabase.* TO 'personalUser'#'localhost';
After granting the appropriate privileges to the user, you should be able to access the MySQL server and use it with Laravel.
If you continue to have issues, you may need to check the configuration of the MySQL server to make sure that it is set up to allow access from the user 'personalUser'. You can refer to the MySQL documentation for more information on how to configure user access: https://dev.mysql.com/doc/refman/8.0/en/adding-users.html

Why is mysql (all the sudden) translating 127.0.0.1 to localhost internally?

I have a strange issue with mysql. I want to connect to the database using the mysql client, and since I want to force connection via TCP I do this:
$ mysql --protocol=TCP -uroot -p -h127.0.0.1
Enter password:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
As you can see, the connection fails, because there is no root access defined for 'root'#'localhost'. This is true - I did not GRANT any privileges to this hostname. However I did specify the root account with full privileges for 'root'#'127.0.0.1'.
I was able to connect to the database in the past with the above mentioned command. However, now it fails. I am not sure if a system update happened in between but something must have changed.
Does anyone have a solution? I would rather not stop the database server for that if possible.
Some more background info. This is running the mysql flavor percona server 5.6 on an ubuntu 14.04 LTE box with everything up to date.

Unable to connect to mysql remotely

I have a mysql database running on a VPS. I can ssh into the host and connect to mysql with no problems. I cannot connect to mysql remotely from my desktop. I have performed the following:
opened port 3306 on the firewall
added my local IP to the remote IPs accepted by mysql. This was done via CPanel
executed
GRANT ALL ON dbname.* TO username#'x.x.x.x' IDENTIFIED BY 'PASSWORD'
to tell mysql to let me connect from the specified address.
I execute the following from the command line on my desktop:
mysql -h x.x.x.x -u username -p
I get a password prompt which indicates I am past the firewall and mysql is responding. When I supply the password, it denies access:
ERROR 1045 (28000): Access denied for user 'username'#'x.x.x.x' (using password: YES)
Have I missed something?
The answer was given in the comments, so I will repeat it here to properly close the thread. alvits suspected that the remote user had not been created. It had been created but his comment prompted me to clean up the user table.
I deleted all remote users including loads that had been created by CPanel or migrated from another host. I then started from scratch doing create user and grant all and it works now.
Thanks!

Access denied for user 'root'#'localhost' (using password: YES) EVEN when the Password works on PhpMyAdmin

I have an issue with accessing MySQL using root and password.
I am trying to connect the Server using PuTTY SSH using
> mysql u root -p
For an unknown reason I can NOT access the Database and I am getting rejected with the following ERROR:
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
The weird thing is that I am using the same password with PhpMyAdmin using Web and I can access everything. I need to run a script that will allow the SQL server
root#localhost user
run the query over the LAN and not the web.
Therefore I need the user to connect using command line SSH or something like that.
How can I fix that issue? the user rott and password WORKS just fine through PhpMyAdmin and not through SSH PuTTY, Why?
Is there something I need to do in order to fix this? I have been working with the Database for 2 years now using the web interface. Now I need to have it working using SSH (22).
Please assist.
thanks in advance.
Arye
It sounds like you need to update the your password for root on MySQL.
Check here: MySQL - ERROR 1045 - Access denied
Thank you all for your help. I have managed to overcome the issue: (see below)
That was FIXED Only when I changed from old password to new. in my.cnf file I have removed the flag for old_password=1 and Restart the service of MySQL.
Then I have created a NEW password (using the old one I had) and it was created with 41 (NEW) Hash length and not 16 (OLD)..
Then I did flush privileges as you recommended - and IT WORKS.
Thank You!
> mysql -h your_host_name -P your_port_number -u your_user_name -p
try with hostname option it should work!
Ubuntu 18.04 running MySQL 5.7.28 creates a file /etc/mysql/debian.cnf. It contains some credentials and other settings. So, this debian-sys-maint user is by default a root equivalent. It is used by certain maintenance scripts on Debian systems, and as a side-effect, allows users with root access on the box to view the plaintext password in /etc/mysql/debian.cnf. If your SSH using a client fails after a fresh install through root try using the credentials set in this file.

Can't access MySQL on LAN server

MySql is installed on a Ubuntu server.
I am running Windows 8.
Logging in through Putty. I can log in to database with both root and webadmin user accounts.
I can also log in through my browser, using <server ip address>/phpmyadmin
My problem is when I try to use command line to log in. I am trying that approach because I am developing a webpage to access the database on that server. It fails to connect, so I thought if command line works, the webpage will also work.
commandline:
mysql -u webadmin -p
or
mysql -u root -p
error 1045 (28000): access denied for user 'webadmin'#'localhost'
(using password: yes)
I added an iptables entry to allow mysql and that didn't work.
Also, the firewall on server is inactive.
You need to grant access to the database. You can read the documentation here: https://dev.mysql.com/doc/refman/5.1/en/grant.html
You can run the following (but be careful as it will leave your DB open)
GRANT ALL ON *.* TO 'root'#'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;
That will allow root to connect from any IP and do any operations to the DB. If that still doesn't work, you might also need to run the following before the 2 lines above
CREATE USER 'root'#'%' IDENTIFIED BY PASSWORD '[your password]';