mySQL password not working when installing Phabricator - mysql

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

Related

MySQL on Windows - Access denied for user 'root'#'localhost' after fresh install

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... ¯\_(ツ)_/¯

Cannot set password for MySQL root 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.

Access denied for user 'root'#'localhost'

I went through all similar or identical questions (this and this, for ex.) but still can't solve the problem.
I am on Xenial and have MySQL 5.7.12. I do not remember setting any password during installation (if it asked, I provided empty one).
I tried to go through password reset using --skip-grant-tables, as described here, it updated the database row, but I still cannot login.
Reconfiguring with sudo dpkg-reconfigure mysql-server-5.7 doesn't do anything, I get this:
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
$ sudo dpkg-reconfigure --force mysql-server-5.7
Checking if update is needed.
This installation of MySQL is already upgraded to 5.7.12, use --force if you still need to run mysql_upgrade
Any ideas?
MySQL 5.7 generates a random root password by itself on installation.
This was a new change in MySQL 5.7.4, and described in the release notes: https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-4.html
The installation process creates only a single root account,
'root'#'localhost', automatically generates a random password for this
account, and marks the password expired. The MySQL administrator must
connect as root using the random password and use SET PASSWORD to
select a new password. (The random password is found in the
.mysql_secret file in the home directory of the effective user running
the script.)
I never find the .mysql_secret file, but the random password is also output in the MySQL error log (e.g. /var/log/mysqld.log on Linux). The notice looks like this:
2016-07-11T15:59:54.922316Z 1 [Note] A temporary password is generated for root#localhost: f14_W1lN7FfP
You could either reinstall everything, which i did. I had initially installed using macos package installer. That didn't get me anywhere.
So uninstalled everything, then upgraded brew, and installed via brew. Running the mysql shell proved a messy affair. Ultimately what worked was mysql -u root -p.
I was running it on localhost, so turns out root password wasn't required. Weirdly, mysql -u root -p <password> threw the "access denied" message.
Proper re-installing helped. Removed everything associated (this instruction, but it is important to specify the version of mysql, e.g. apt-get --yes purge mysql-server-5.7 mysql-client-5.7, and I also deleted mysql-common and all dependencies to be sure).
Then installed again (apt-get install mysql-server mysql-client) and when it asked for a password, this time, I gave it one. It works now.

Cannot login to MySQL in Mac OS X Yosemite

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?

Locked out of MySQL server - CentOS

I have a server running CentOS and I installed myphp, phpmyadmin, mysql, mysql-server and it asks me for a password when trying to run the mysql safe install. I have not set a password and it says if you have not set one, then press enter, but this doesn't not work. Also I can't stop mysql and reinstall because that gives me the error:
mysql access denied for user 'root'#'localhost'
I've looked about a few places online and I cant find any fixes.
If it's possible, shut down the mysql daemon (service mysql stop). You can start it in safe mode to skip authorization with mysqld --skip-grant-tables. Then you can connect to it as root without password and reset the password.
Ok so what I did was service mysql stop and then mysqld_safe --skip-grant-tables & whilst I was in the root directory. What I did not realise was that when I do this, I am now in the SQL command line. This was my first time using mysql and so when the [root#blahblah] wasn't showing in the left side, I thought that the process has crashed but that was not true. Once I realised that I was actually in the SQL command line I was able to change my password.