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?
Related
I've installed the latest MySQL on Windows 10 Pro. I included the wizard steps to set up initial values and chose to set it up as a dev machine. I left everything to the default values. After installing and restarting the machine, there's no way to connect to the database it seems.
I get the MySQL Error 1045: Access denied for user 'root'#'localhost' (using password: YES) error both in MySQL Workbench as well as the MySQL Shell.
I've tried to set skip-grant-tables in my.ini as that comes up in a lot of answers on here. When I set that and try to start the MySQL80 Service, it shuts itself down within seconds again.
I've also tried to start with mysqld.exe --skip-grant-tables as per this answer but that gave me the error that it couldn't find C:\Program Files\MySQL\MySQL Server 8.0\data. This folder indeed didn't exist, after making this folder myself and running mysqld.exe --skip-grant-tables again, 3 files were added to this folder but I'm immediately thrown back to my CMD shell and no mysqld.exe process is running.
To reiterate, this is a Windows 10 machine, answers about sudo mysql or /etc/my.conf are N/A unfortunately.
Workbench, MySQL Shell and CMD Prompt were all running as Administrator in the above steps.
Did you try with "-p" and password "password"?
Reinstalled MySQL with legacy authentication and the weakest password it'll accept and now it works... ¯\_(ツ)_/¯
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 seem to be unable to set a valid MySQL root password that Phabricator can use during the installation.
Every time I try to restart the phd daemons (as per these instructions: https://gist.github.com/sparrc/b4eff48a3e7af8411fc1) I get the following exception:
[2018-09-20 08:38:09] EXCEPTION: (PhabricatorClusterStrandedException) Unable to establish a connection to any database host (while trying "phabricator_config"). All masters and replicas are completely unreachable.
AphrontConnectionQueryException: Attempt to connect to root#127.0.0.1 failed with error #1698: Access denied for user 'root'#'localhost'. at [<phabricator>/src/infrastructure/storage/lisk/PhabricatorLiskDAO.php:158]
I was, however, able to successfully complete the ./bin/storage upgrade Phabricator command after reinstalling MySQL.
I have tried:
sudo dpkg-reconfigure mysql-server-5.7 - Didn't prompt for a new password
Logging in with mysqld_safe --skip-grant-tables & and running update commands on the root password. All seems to be successful, but as soon as I try Phabricator again, I get the exception.
Looking for temporary passwords:
sudo grep "temporary password" /var/log/mysqld.log
grep: /var/log/mysqld.log: No such file or directory
Note that I am using ./bin/config set mysql.pass 'mypassword' after changing it using any of the methods above. I've tried no password as well, which doesn't work. Once I have run the Phabricator storage upgrade command, I can no longer access mySQL at all and any steps to reset passwords seem to take no effect.
I'm running MySQL 5.7 and PHP 5.6 on Ubuntu 18.04
(After two hours of researching how to use mysql commands in the terminal, I can finally post this question, BTW if anyone with macOS is having the same trouble that can't use mysql commands in the terminal, go straight to this straight to this link: solution.)
I have a Mac os Sierra, I'm completely new to MySQL. I first downloaded the workbench and the MySql server, it gave me a temp password, I created a local connection, it worked. Then, I deleted the old connection, and created another connection, it asks for the password, and it wouldn't work, so right now I'm trying to reset and change my mysql password, but I've been having a lot of trouble with it.
Since the SQL office website only has instructions for windows and unix, and I'm rather new to bash, I tried to find solutions somewhere else like this site.
1. Attempt
When I tried the solution from this link site1, as I try the first step, it asks for a password which I don't have, I tried the old password just to try and it didn't work.
YupengdeMacBook-Pro:~ yinyupeng$ sudo /usr/local/mysql/support-files/mysql.server stop
Password:
Then, I realized that I can close my server directly in the MacOS setting, I did that, and I jumped to the second step directly, it still asks for a password:
YupengdeMacBook-Pro:~ yinyupeng$ sudo mysqld_safe --skip-grant-tables
Password:
So I'm stuck here, can't go further with this solution.
2. Attempt
then I tried this site2, but as I type the first line, it tells me this:
YupengdeMacBook-Pro:~ yinyupeng$ mysql -u root
ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO)
Umm... ok, so then I tried to find solutions for that "access denied" error, but with little results.
So I'm not sure what to do now, please help, thank you very much.
BTW, my SQL version is:
YupengdeMacBook-Pro:~ yinyupeng$ mysql --version
mysql Ver 14.14 Distrib 5.7.19, for macos10.12 (x86_64) using EditLine wrapper
YupengdeMacBook-Pro:~ yinyupeng$
You can try reseting the root password by running MySQL in Safe Mode.
Here are the steps:
Stop MySQL:
sudo /usr/local/mysql/support-files/mysql.server stop
Start it in safe mode:
sudo mysqld_safe --skip-grant-tables
This will be an ongoing command until the process is finished so open another shell/terminal window, and..
Log in without a password as root:
mysql -u root
Update root (and any other user's) password)
FLUSH PRIVILEGES;
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
\q
Restart MySQL in normal mode
sudo /usr/local/mysql/support-files/mysql.server start
Reference: https://coolestguidesontheplanet.com/how-to-change-the-mysql-root-password/
Note: this is pretty much a copy-paste from the reference link. this is pretty standard reset procedure, but just documented better in that guide compared to mysql reference docs.
You can edit your mysql configuration file and add skip-grant-tables to the section [mysqld]
or
Start mysqld and send it to background
mysqld_safe --skip-grant-tables &
I had mysql already installed in my system and I uninstalled it because it was not running successfully.
Now when I installed a new version of mysql, the server starts and stops successfully. But it still accepts the password of my old mysql.
If I try to change the password, which I need to because it says my old password has expired when I try to connect it to workbench, it gives me the following error:
File './mysql/user.MYD' not found (Errcode: 2 - No such file or directory)
I also tried running this command:
mysql -uroot -p
It accepts my old password and then if I further run any other command, example
mysql> USE mysql;
It asks me to reset the password and when I do it again gives me the above error
If you've trashed your MySQL system tables you'll need to recreate them with the mysql_install_db command-line tool or something equivalent. This is done while the server process is stopped and should initialize everything correctly.