I'm creating a backend node server on Windows. I'm using MySQL8.0, and since the beginning, my db root has had a password set. In the middle of working, MySQL Workbench kicked me out of my database connection and I haven't been able to connect since, either on Workbench or in command line. I keep getting the following error:
Your connection attempt failed for user 'root' from your host to server at
127.0.0.1:3306:
Access denied for user 'root'#'localhost' (using password: YES)
Things I've attempted:
Intentionally entering in wrong/different password
RESULT: Before I started fiddling with everything, I got an error related to invalid credentials (ie. not the same as the Access denied). After I did all the following, if the server is running, same "Access denied" error. If the server is not running, "can't connect to server on 'localhost'" error.
mysql -u root -p -h 127.0.0.1 -P 3306
RESULT: Request for password, "Access denied."
mysqld.exe -u root --skip-grant-tables
RESULT: Multiple [Server] "Can't create test file" errors followed by [Server] "Aborting" This is the same whether the server is running or not.
mysql_secure_installation
RESULT: I'm asked for my password. If server is running, get "Access denied" error. If turned off, get "can't connect to server on 'localhost'" error.
Attempted to reinstall mysql as a service
RESULT: I now have two mysql services: MySQL (new) and MySQL80 (original). The issue persists, no matter which is running.
mysqld --skip-grant-tables
mysql -u root -p
RESULT: This doesn't have errors now? Except I'm also requested for a password. Same "Access denied" error.
Followed the instructions to reset my password listed at Mysql's website: https://dev.mysql.com/doc/refman/8.0/en/resetting-permissions.html
RESULT: I can finally connect! Except I open up Workbench to find all my databases missing. I realize I have MySQL service running, and not MySQL80. I switch to that. The "Access denied" error is back.
sc remove MySQL
Repeated instructions for resetting password
RESULT: Now only have MySQL80. When using mysql-init.txt to run server, I can log in on Workbench, but all my databases are missing here too. I close out, restart the service manually. Back to "Access denied" error.
My app's node server has had no issue connecting to MySQL80 when it was running, despite all this. It's using a non-root user to login.
Related
Hi I'm trying to get a mariadb/freeradius/daloradius server up but i keep getting this log from systemctl -xe on my mariadb/mysql service, i came across that after figuring it was the sql connection that was problematic, freeradius shows me the same :
I'm getting frustrated, i ran across almost every config file, all should be in order but no this keeps happening, the radius server is trying to connect to my root sql user when i pointed to him in his config file that he should use the one i created especially for him and i can't manage to understand why, do mariadb needs the root credentials before even allowing it to connect to it ? I'm clueless please help.
This message tell you. that either the credentials in your config is not ok or that root user is not authorized to login.
Best practice is to take your mysql config and try to connect with the mysql command:
mysql -h yourconfigurationhost -u yourconfiguration user -p yourconfiguration password yourconfigurationdatabase
Be shure doing this with your application user.
I am trying to get MySQL running on my localhost. This never happened to me before, but upon installation sudo apt-get install mysql-server did not ask me for the initial password.
After searching for answers to "reset" my password and battling with directory permissions, i am currently at this state:
The mysqld_safe solution:
After rebooting my computer, mysql -u root -p will ask me for my password, and after i enter it, it will complain with ERROR 1698 (28000): Access denied for user 'root'#'localhost'
If i instead try mysql -u root (no password), it will say ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
If i run the advice that other people have posted about resetting the password via mysqld_safe --skip-grant-tables, then i run across some hiccups along the way:
First i run sudo service mysql stop
Then sudo mysql_safe --skip-grant-tables will say mysqld_safe Directory '/var/run/mysqld' for UNIX socket file don't exists.
I can fix that if i do sudo mkdir -p /var/run/mysqld and sudo chown mysql /var/run/mysqld
After this, running mysqld_safe will run with the message Starting mysqld daemon with databases from /var/lib/mysql and then hang. And Ctrl+C doesn't get me out of that.
In a new terminal window i can now actually connect with mysql -u root and get the mysql> prompt.
I can set a new password with use mysql; update user set authentication_string=password('0000') where user='root';flush privileges; which will tell me it successfully updated the row with the message Rows matched: 1 Changed: 1 Warnings: 1
The warning only states: 'PASSWORD' is deprecated and will be removed in a future release.
And after all this, i'm back at square one: The process still hangs, so i have to reboot because killall mysqld_safe says no process found. After rebooting and entering my new password 0000, i will get access denied.
The system is Linux 4.15.0-48-generic #51-Ubuntu SMP.
The mysqladmin solution
If i run mysqladmin -u root password '0000' (without sudo), i get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'#'localhost''
If i run it with sudo, i get:
mysqladmin: [Warning] Using a password on the command line interface can be insecure.
Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
This last one doesn't really tell me anything in regards of whether the password change happened or not; has it been refused or not (since it's a warning, not an error, i would assume it should go through), but in either case, trying to connect with 0000 still says "access denied".
Any advice on how to fix this is greatly appreciated.
I didn't quite solve the problems with mysql directly; However for myself, the acceptable solution was switching to a different database software, but it's still a MySQL system, and it got me up and running. So if anyone gets stuck on existing solutions not working like i did, maybe this comes in handy to get you on the road and finally writing code again.
What i did was:
Purged mysql off my system
Manually deleted /etc/mysql and /var/lib/mysql (don't know if this step was necessary)
apt clean, apt autoremove, apt update
Installed mariadb
Followed these instructions to rid myself of the timeout bug
Used the mysqld_safe --skip-grant-tables method to create a new user with all privileges, since connecting with root always kept failing
PHP + MariaDB now working again.
I am following mysql on Cygwin.
# To begin MySQL setup run the following:
mysql_install_db
# Run mysql - you'll get a firewall alert from windows if you have it active.
mysqld_safe &
# Immediately following that, it would be wise to run the following:
mysql_secure_installation
During the mysql_install_db, I was asked who the database (DB) would be for. I specified a non-administrator account nonadmin.
For the mysql_secure_installation process, I followed the similarly named MariaDB page. In contrast to the description, I was told that I had no root password, so I set it to the same as my cygwin and windows administrator account.
I lost track of whether which account was used for each of the three commands above, but here is what I remember:
mysql_install_db: Ran as nonadmin, but prompted for admin password
mysqld_safe: Run as nonadmin
mysql_secure_installation: Attempted as nonadmin, abandoned, and
completed as administrator account admin
It seems that I should restart the server after the final step. Using ps -ef, I noted that process mysqld belongs to nonadmin. Using nonadmin, I attempted the mysqladmin shutdown command at mysql on Cygwin. I get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'nonadmin'#'localhost' (using password: NO)'
I tried the variation of the command that prompts the user for a password: mysqladmin -p shutdown. I did this twice, entering the cygwin/windows passwords for nonadmin and admin. Both times, I get:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'nonadmin'#'localhost' (using password: YES)'
This totalled 3 attempts. I then switched to the admin account and retried all 3 attempts. I got the above messages, but with the username admin:
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'admin'#'localhost' (using password: NO)'
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'admin'#'localhost' (using password: YES)'
So no joy connecting to the daemon to shut it down. As an alternative, I want to avoid clobbering mysqld with kill -9 because I like things to terminate cleanly (though I will probably do so soon).
As another alternative, I've come across references to /etc/init.d, but I have no such file.
Can anyone please explain why I can't connect to the daemon to shut it down?
Also, I'm new to MySQL, so if possible, it'd be nice to find a way back to the process at mysql on Cygwin rather than deviating from it too much.
Thanks.
What I ended up doing was kill -9 on all mysql looking processes shown by ps -ef. I then deleted /var/lib/mysql -- and accidentally deleted all of /var/lib/*. Subsequently, therefore, I reinstalled all of my Cygwin packages, thus starting from a clean slate.
I also found the following more detailed process at this alaya page for installing a MySQL/MariaDB database on Cygwin, after which I was able to shut down the MySQL server.
from the Administrator terminal run:
mysql_install_db
Start the mysql server:
mysqld_safe &
then run:
mysql_secure_installation
You should then be able to log in to MariaDB from a non-administrative shell with:
mysql -u root -p
The initial mysql_install_db step generates the following useful looking information, which I'm capturing here because I'm not sure if there is a way to get it again.
Installing MariaDB/MySQL system tables in '/var/lib/mysql' ...
2019-05-01 23:00:06 0 [Warning] InnoDB: innodb_open_files 300 should not be greaterthan the open_files_limit 256
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:
'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h fmaPC password 'new-password'
Alternatively you can run:
'/usr/bin/mysql_secure_installation'
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.
You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mysqld_safe --datadir='/var/lib/mysql'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mysql-test-run.pl
Please report any problems at http://mariadb.org/jira
The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
During the mysql_secure_installation step, I followed the recommendation to set a root password. Instead of the mysql -u root -p step, then, I could instead issue the following to stop the MySQL server:
mysqladmin -u root -p shutdown
I made an important discovery made about this process from the point of view of a user without administrator rights. Contrary to what is suggested on the alaya page cited above, the above process does not have to be done from an administrator account. Importantly, the user accounts with which one can connect to the MySQL server has nothing to do with the user accounts on the host system (Windows or *nix) (a fact that I got from perusing MariaDB knowledgebase). I suspect that any user on the host system can connect to any user account on the server via the socket that it presents [1], with the right password.
I also found that the above process works on a machine that has very restrictive Windows firewall policies. Even if the server (the mysqld_safe & step) and client (the mysql -u root -p step) are started from the same non-administrative account, the Windows firewall will issue a warning about curtailing some features. I suspect that the trigger is the creation of a socket for connecting to the server. Despite the warning, however, ps -ef shows the server to be running. Therefore, I suspect that the firewall restriction consists of allowing only loop-back connections. The mysql_secure_installation step apparently disallows external connections, and I found that after this step, stopping and relaunching the server no longer triggers the firewall warning. So the effect of mysql_secure_installation seems to persist into subsequent sqld launches, at least when they are started via mysqld_safe.
[1] "Present" might not be the right terminology here, as I'm more of an analyst rather than a developer or administrator.
Here is my problem: I cannot login to MySQL since I forgot the temporary password, i.e., the one that was assigned to me when I installed MySQL (if I type mysql in the command line, I receive this error: ERROR 1045 (28000): Access denied for user 'mona'#'localhost' (using password: NO). I receive the same error when I try with mysql -u root), so I tried the following to fix it:
I turned off MySQL
Then I created a file called restore in which I wrote SET PASSWORD FOR root#localhost=PASSWORD('');
Finally, sudo mysqld_safe --init-file=/usr/local/mysql/support-files/restore which didn't work. Then I tried step 3 with this command sudo /usr/local/mysql/support-files/mysql.server start and I got this error ERROR! The server quit without updating PID file (/var/run/mysqld/mysqld.pid).
In order to fix the last error, I tried the followings:
ps aux | grep mysql and killed MySQL processes. Then I started MySQL server but I received the same error again.
I checked my.cnf file in /private/etc (everything was commented in this file except this line: pid-file = /var/run/mysqld/mysqld.pid, but I found there is no mysqld folder in /var/run, instead it is located in this path: /usr/local/mysql-5.7.11-osx10.9-x86_64/bin/).
Now, I feel confused: why in /usr/local/, there are both mysql folder and mysql-5.7.11-osx10.9-x86_64?? what is their difference then? (I know the one I installed is the latter one)
How can I fix this issue?
I have one instance of mysql.
It is running at "C:\Program Files\MySQL\MySQL Server 5.5\bin\"
Now, when I try to connect using "heidisql" tool using user name as "root" and password as "eagle" then it connects properly and show the databases which I had created.
Now I open Command Prompt and go to the location where my MySQL service is running, Here I executed the same command but not working like shown below,
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -uroot -peagle
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: YES)
Also, now I closed all the mysql server and then typed
"C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql"
then it connects properly. I am not getting as all my mysql server is off then whom it is connecting to.
I am suspecting some where I have 2 instances of mysql running but I checked ControlPanel, Services running, No where I found any other service.
If any body faced such issue and solved, please suggest me solution.
There can be some root users on the same MySQL server which differ by host, for example - 'root'#'localhost', 'root'#'%', 'root'#'server'. All these users can have different passwords. Check it firstly, and specyfy -h or --host option in your command line.
Also, command line syntax is incorrect, it should be like this -
mysql -u root -peagle