Brew MySQL version 8.0.12 Sequel Pro connection failure - mysql

I'm getting the exact same problem as this question. The problem is that the solution isn't really organized to be easily understandable in my situation.
MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
I don't have anything to initialize the DB in macs system preferences. The second answer says:
Go to my.cnf file and in section [mysqld] add line:
default-authentication-plugin=mysql_native_password
Login to mysql server from terminal: run mysql -u root -p, then inside shell execute this command: ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '[password]';
exit from mysql shell with exit and run sudo service mysqld restart
The information given as to where to find my.cnf is found in this post and states:
mysql --help
Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
The following options may be given as the first argument:
--print-defaults Print the program argument list and exit.
--no-defaults Don't read default options from any option file.
--defaults-file=# Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
It looks like there are three areas where the my.cnf file is and I have no idea what one to edit, or how I should edit it.
Another solution I have found is from this thread:
After installing MySQL, authenticate using the CLI e.g
mysql -uroot
Then run the following command to use the old authentication method:
ALTER USER root#localhost IDENTIFIED WITH mysql_native_password BY 'PASSWORD';
Lastly, flush the privileges:
FLUSH PRIVILEGES;
Now you should able to connect using SequelPro again (using the specified password).
The second solution is reported to cause sequel pro to crash by multiple users in the answers comments, so I'm guessing it's hacky.
How do I connect mysql ver 8.0.12 to sequel pro? Should I just use another GUI? It seems this problem happens with workbench as well
Just incase it gets asked I'm using Mac OSX Sierra 10.13.5

Here is what worked for me on macOS Mojave (10.14.3) with brew installed mysql 8.
1) Add this line to my.cnf located in /usr/local/etc
default-authentication-plugin=mysql_native_password
2) Connect to your running mysql server on the command line as root user and then enter:
ALTER USER 'root'#'localhost'
IDENTIFIED WITH mysql_native_password
BY 'password';
replace 'password' with the root password for your mysql server.
3) Just to be sure all the changes are picked up be the mysql server I restarted the server.
These instructions were taken from the mysql.com documentation which you can find here:
https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-caching-sha2-password-compatible-connectors

Related

Problems after installing MySql on Linux WSL

After a new installation of MySQL on WSL linux distribution a whole sequence of issues ocurred. Solutions are described on different posts, but I thought it would be good to have them on one place, since it concerns clean new installations of both mysql and WSL on a new Windows 11 PC, without any previous configuration changes, so 100% reproducible with the given versions. I followed the installation manuals for WSL and mysql expecting this would work out-of-the-box. My intention was to run MySQL instance on WSL and connect to it from MySQL Workbench running on the hosting Windows. Below is description of steps I've performed and how I solved the issues which occurred. Maybe it helps someone in the same scenario, or maybe someone can propose better solutions.
WSL installation
On a (new) Windows 11 PC, executed PowerShell command:
wsl --install -d Ubuntu
This installed Ubuntu 22.04.1 LTS
In the distribution set up username/password and performed necessary updates and upgrades according to https://learn.microsoft.com/en-us/windows/wsl/install.
MySQL installation
According to https://learn.microsoft.com/en-us/windows/wsl/tutorials/wsl-database
$ sudo apt install mysql-server
This installed:
mysql Ver 8.0.31-0ubuntu0.22.04.1 for Linux on x86_64 ((Ubuntu))
Tried to start the instance:
$ sudo /etc/init.d/mysql start
Following warning was reported during the instance startup:
su: warning: cannot change directory to /nonexistent: No such file or directory
MySQL uses a user named 'mysql' who has '/nonexistent' set up as the home directory after installation. The home directory is registered in the file '/etc/passwd'. When you open the file in an editor, you will see the line for 'mysql' user with the '/nonexistent:' directory.
mysql:x:108:117:MySQL Server,,,:/nonexistent:/bin/false
This directory has to be changed to an existing one, e.g.: '/var/lib/mysql'. For this the instance must be stopped first:
$ sudo /etc/init.d/mysql stop
Then the home directory can be set with the command:
$ sudo usermod -d /var/lib/mysql/ mysql
After this the instance will start without the previous warining, but the following error appeared:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (13)
To solve this error, find where the mentioned mysqld.sock file is located. Do not stop the instance before running the command:
$ sudo find / -type s
Find the file in the output, in my case it was: '/run/mysqld/mysqld.sock'.
Find 'my.cnf' file under '/etc', in my case: '/etc/mysql/my.cnf'. Edit this file, do not use the Windows notepad.exe, but better notepad++, in order not to change the encoding, or add extra '.txt' extension.
Add following lines at the end of the file, using the exact file location:
[mysql]
socket=/run/mysqld/mysqld.sock
I have searched for references to '/var/run' path in other .cnf files under '/etc/mysql' directory and changed them to '/run', because the '/var/run' does not exist on my distribution.
After this step, the instance can be started without any errors, or warnings.
Set up MySQL root user
While is was possible to start mysql with:
$ sudo mysql
There attempt to access the instance with the root user:
$ mysql -u root -p
Resulted in error:
Access denied for user 'root'#'localhost' (using password: NO)
The user was pre-created during installation without password, but yet cannot access the instance. To fix this issue, the 'root' user needs to be re-created:
$ sudo mysql
mysql> drop user 'root'#'localhost';
mysql> create user 'root'#'localhost' identified by '' ;
mysql> grant all privileges on *.* to 'root'#'localhost' WITH GRANT OPTION;
mysql> flush privileges;
Connect from Workbench running on Windows
For connecting to Workbench, I've tried to use previously configured 'root' user without password.
First the IP address of WSL needs to be detected. One way is to install net-tools and use ifconfig command:
$ sudo apt install net-tools
$ ifconfig
Then, the IP address can be seen under <BROADCAST, RUNNING, MULTICAST> section in the output:
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.114.54 netmask 255.255.240.0 broadcast 192.168.127.255
Here it was 192.168.114.54
Simpler way is to get this address from Windows PowerShell command:
wsl hostname -I
Using this address from Workbench resulted in error connecting to the server. I've solved this problem by changing the 'bind-address' setting found in the '/etc/mysql/mysql.conf.d/mysqld.cnf' file. This was previously set to 127.0.0.1. It had to be changed to:
bind-address=0.0.0.0
After this step, connection attempt from Workbench resulted in access error for the 'root' user, but it confirmed, that server was now accessible:
Failed to Connect to MySQL at 192.168.114.54:3306 with user root
Access denied for user 'root'#'192.168.112.1'
Problem with the 'root' user accessing the instance was, that each MySQL user is bound to a specific host. In my case the 'root' was bound to 'localhost'. I needed to create a new 'root' user bound to '192.168.112.1':
mysql> create user 'root'#'192.168.112.1' identified by '';
mysql> grant all privileges on . to 'root'#'192.168.112.1' WITH GRANT OPTION;
mysql> flush privileges;
After this step I could connect to MySQL instance from Workbench running on the hosting Windows without errors.

mysqli_real_connect(): (HY000/1045): Access denied for user 'phpmyadmin'#'localhost' (using password: YES)

I am doing an online course from coursera where they tolm me to install phpmyadmin.
NOW I am a total beginner in this thing so I am not able to do much research upon that and now somehow, after I installed MySQL and phpmyadmin, in the localhost, I am getting some errors, is that common? Because the other participants in the course are not getting them. If that's fatal or will limit some of my obvious abilities, please tell me how to cure it.
BTW If you didn't noticed the errors are:
mysqli_real_connect(): (HY000/1045): Access denied for user 'phpmyadmin'#'localhost' (using password: YES)
and
Connection for controluser as defined in your configuration failed.
Some more details:
PHP version is 7.4
Operating System is Ubuntu 20.04
I was using MaridDb solved this issue with the following:
sudo systemctl stop mariadb
sudo mysqld_safe --skip-grant-tables --skip-networking &
mysql -u root
You will see a prompt like below:
Type help; or \h for help. Type \c to clear the current input statement.
MariaDB [(none)]> FLUSH PRIVILEGES;
For MySQL 5.7.6 and newer as well as MariaDB 10.1.20 and newer
ALTER USER 'root'#'localhost' IDENTIFIED BY 'new_password';
OR:
For MySQL 5.7.5 and older as well as MariaDB 10.1.20
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('new_password');
I've just installed LAMP on a new PC, and got the same problem.
Linux Mint 20 + MariaDB.
Password for root and phpmyadmin was already ok, but the error was still there.
Finally I discovered another configuration file, that sets the phpmyadmin password; you have to edit it:
$ sudo nano /etc/dbconfig-common/phpmyadmin.conf
set the correct password (= dbc_dbpass) for user dbc_dbuser='phpmyadmin'
Use ctrl-O to save, then ctrl-X to exit. Then launch the command:
$ sudo dpkg-reconfigure phpmyadmin
(Do NOT reinstall the DB).
In my PC il works!
I had a similar issue with mysql 8.0.22 and Ubunutu 20.04.3lts after installation despite setting up the phpmyadmin user during the installation it wouldn't let me in with the password I set.
I solved it by logging in at the command line using
sudo mysql
Then changed the password by the below and I could then log in
ALTER USER 'phpmyadmin'#'localhost' IDENTIFIED BY 'new-password-here';
I had the same problem by changing the password of the root user and the problem was solved by changing the content of the config.inc.php file inside the xampp\phpMyAdmin folder.
Open the file with Notepad, then enter the defined password in front of the password field and that's it
Error image
---The part where the password must be entered

Why am I getting the error "Authentication plugin 'caching_sha2_password' cannot be loaded: The specified module could not be found."? [duplicate]

I am connecting MySQL - 8.0 with MySQL Workbench and getting the below error:
Authentication plugin 'caching_sha2_password' cannot be loaded:
dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image
not found
I have tried with other client tool as well.
Any solution for this?
you can change the encryption of the password like this.
ALTER USER 'yourusername'#'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';
Note: For MAC OS
Open MySQL from System Preferences > Initialize Database >
Type your new password.
Choose 'Use legacy password'
Start the Server again.
Now connect the MySQL Workbench
For Windows 10:
Open the command prompt:
cd "C:\Program Files\MySQL\MySQL Server 8.0\bin"
C:\Program Files\MySQL\MySQL Server 8.0\bin> mysql -u root -p
Enter password: *********
mysql> ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'newrootpassword';
Query OK, 0 rows affected (0.10 sec)
mysql> exit
Alternatively, you can change the my.ini configuration as the following:
[mysqld]
default_authentication_plugin=mysql_native_password
Restart the MySQL Server and open the Workbench again.
I had the same problem, but the answer by Aman Aggarwal didn't work for me with a Docker container running mysql 8.X.
I loged in the container
docker exec -it CONTAINER_ID bash
then log into mysql as root
mysql --user=root --password
Enter the password for root (Default is 'root')
Finally Run:
ALTER USER 'username' IDENTIFIED WITH mysql_native_password BY 'password';
You're all set.
You can change the encryption of the user's password by altering the user with below Alter command :
ALTER USER 'username'#'ip_address' IDENTIFIED WITH mysql_native_password BY
'password';
OR
We can avoid this error by make it work with old password plugin:
First change the authentication plugin in my.cnf file for Linux / my.ini file in Windows:
[mysqld]
default_authentication_plugin=mysql_native_password
Restart the mysql server to take the changes in affect and try connecting via MySQL with any mysql client.
If still unable to connect and getting the below error:
Unable to load plugin 'caching_sha2_password'
It means your user needs the above plugin. So try creating new user with create user or grant command after changing default plugin. then new user need the native plugin and you will able to connect MySQL.
Thanks
Currently (on 2018/04/23), you need to download a development release. The GA ones do not work.
I was not able to connect with the latest GA version (6.3.10).
It worked with mysql-workbench-community-8.0.11-rc-winx64.msi (from https://dev.mysql.com/downloads/workbench/, tab Development Releases).
Ok, wasted a lot of time on this so here is a summary as of 19 March 2019
If you are specifically trying to use a Docker image with MySql 8+, and then use SequelPro to access your database(s) running on that docker container, you are out of luck.
See the sequelpro issue 2699
My setup is sequelpro 1.1.2 using docker desktop 2.0.3.0 (mac - mojave), and tried using mysql:latest (v8.0.15).
As others have reported, using mysql 5.7 works with nothing required:
docker run -p 3306:3306 --name mysql1 -e MYSQL_ROOT_PASSWORD=secret -d mysql:5.7
Of course, it is possible to use MySql 8+ on docker, and in that situation (if needed), other answers provided here for caching_sha2_password type issues do work. But sequelpro is a NO GO with MySql 8+
Finally, I abandoned sequelpro (a trusted friend from back in 2013-2014) and instead installed DBeaver. Everything worked out of the box. For docker, I used:
docker run -p 3306:3306 --name mysql1 -e MYSQL_ROOT_PASSWORD=secret -d mysql:latest --default-authentication-plugin=mysql_native_password
You can quickly peek at the mysql databases using:
docker exec -it mysql1 bash
mysql -u root -p
show databases;
I was installing MySQL on my Windows 10 PC using "MySQL Web Installer" and was facing the same issue while trying to connect using MySQL workbench. I fixed the issue by reconfiguring the server form the Installer window.
Clicking on the "Reconfigure" option it will allow to reconfigure the server. Click on "Next" until you reach "Authentication Method".
Once on this tab, use the second option "Use Legacy Authentication Method (Retain MySQL 5.x Compatibility)".
Keep everything else as is and that is how I solved my issue.
Note: For Linux (Debian, Ubuntu, Mint)
I got this error:
MySQL Error Message: Plugin caching_sha2_password could not be loaded: /usr/lib/x86_64-linux-gnu/mariadb19/plugin/caching_sha2_password.so: cannot open shared object file: No such file or directory
I solved it with these steps:
Enter on mysql console: $ mysql -u root -p, if you don't have a password for root user, then:
Use mysql db: mysql> use mysql;
Alter your user for solve the problem: mysql> ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
Exit... mysql> quit;
Done!
like this?
docker run -p 3306:3306 -e MYSQL_ALLOW_EMPTY_PASSWORD=yes -d mysql --default-authentication-plugin=mysql_native_password
mysql -uroot --protocol tcp
Try in PWD
https://github.com/GitHub30/docs/blob/change-default_authentication_plugin/mysql/stack.yml
or You shoud use MySQL Workbench 8.0.11.
Open MySQL Command Line Client
Create a new user with a new pass
Considering an example of a path to a bin folder on top, here's the code you need to run in the command prompt, line by line:
cd C:\Program Files\MySQL\MySQL Server 5.7\bin
MySQL -u root -p
current password...***
CREATE USER 'nativeuser'#'localhost'
IDENTIFIED WITH mysql_native_password BY 'new_password';
Then, you can access Workbench again (you should be able to do that after creating a new localhost connection and using the new credentials to start using the program).
Set up a new local host connection with the user name mentioned above (native user), login using the password (new_password)
Courtesy: UDEMY FAQs answered by Career365 Team
For Windows 10,
Modify my.ini file in C:\ProgramData\MySQL\MySQL Server 8.0\
[mysqld]
default_authentication_plugin=mysql_native_password
Restart the MySQL Service.
Login to MySQL on the command line, and execute the following commands in MySQL:
Create a new user.
CREATE USER 'user'#'localhost' IDENTIFIED BY 'password';
Grant all privileges.
GRANT ALL PRIVILEGES ON * .* TO 'user'#'localhost';
Open MySQL workbench, and open a new connection using the new user credentials.
I was facing the same issue and this worked.
Although this shouldn't be a real
solution, it does work locally if you are stuck
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY '';
This is my databdase definition in my docker-compose:
dataBase:
image: mysql:8.0
volumes:
- db_data:/var/lib/mysql
networks:
z-net:
ipv4_address: 172.26.0.2
restart: always
entrypoint: ['docker-entrypoint.sh', '--default-authentication-plugin=mysql_native_password']
environment:
MYSQL_ROOT_PASSWORD: supersecret
MYSQL_DATABASE: zdb
MYSQL_USER: zuser
MYSQL_PASSWORD: zpass
ports:
- "3333:3306"
The relevant line there is entrypoint.
After build and up it, you can test it with:
$ mysql -u zuser -pzpass --host=172.26.0.2 zdb -e "select 1;"
Warning: Using a password on the command line interface can be insecure.
+---+
| 1 |
+---+
| 1 |
+---+
For those using Docker or Docker Compose, I experienced this error because I didn't set my MySQL image version. Docker will automatically attempt to get the latest version which is 8.
I set MySQL to 5.7 and rebuilt the image and it worked as normal:
version: '2'
services:
db:
image: mysql:5.7
I found that
ALTER USER 'username'#'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
didn't work by itself. I also needed to set
[mysqld]
default_authentication_plugin=mysql_native_password
in /etc/mysql/mysql.conf.d/mysqld.cnf
on Ubuntu 18.04 running PHP 7.0
Here is the solution which worked for me after MySQL 8.0 Installation on Windows 10.
Suppose MySQL username is root and password is admin
Open command prompt and enter the following commands:
cd C:\Program Files\MySQL\MySQL Server 8.0\bin
mysql_upgrade -uroot -padmin
mysql -uroot -padmin
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY
'admin'
If you are getting this error on GitLab CI like me:
Just change from latest to 5.7 version ;)
# .gitlab-ci.yml
rspec:
services:
# - mysql:latest (I'm using latest version and it causes error)
- mysql:5.7 #(then I've changed to this specific version and fix!)
Open my sql command promt:
then enter mysql password
finally use:
ALTER USER 'username'#'ip_address' IDENTIFIED WITH mysql_native_password BY 'password';
refer:https://stackoverflow.com/a/49228443/6097074
Thanks.
For me this started happening because on a project, I was using Docker image mysql:latest (which was version 5, and which was working fine), and during a later build, the latest version was switched to version 8, and stopped working. I changed my image to mysql:5 and I was no longer getting this error.
This error comes up when the tool being used is not compatible with MySQL8, try updating to the latest version of MySQL Workbench for MySQL8
If you still want to use the new authentication method, the proper solution is to install the mariadb-connector-c package. For Alpine, run:
apk add mariadb-connector-c
This will add the missing caching_sha2_password.so library into /usr/lib/mariadb/plugin/caching_sha2_password.so.
Almost like answers above but may be in simple queries, I was getting this error in my spring boot application along with hibernate after MySQL upgrade. We created a new user by running the queries below against our DB. I believe this is a temp work around to use sha256_password instead of latest and good authentication caching_sha2_password.
CREATE USER 'username'#'localhost' IDENTIFIED WITH mysql_native_password BY 'pa$$word';
GRANT ALL PRIVILEGES ON * .* TO 'username'#'localhost';
MySQLWorkbench 8.0.11 for macOS addresses this.
I can establish connection with root password protected mysql instance running in docker.
If you are trying to connect to a MySQL server from a text-based MySQL client from another computer (be it Docker or not)
Most answers here involve connecting from a desktop client, or ask you to switch to an older authentication method. If you're connecting it with the MySQL client (text-based), I made it work with a Debian Buster in a Docker container.
Say you have the apt system and wget set up, do the following:
sudo apt-get update
sudo apt-get install lsb-release -y
Download a Debian package which update apt sources for you from the MySQL web site.
sudo dpkg -i mysql-apt-config_0.8.13-1_all.deb and select the options you want. In my case I only need MySQL Tools & Connectors to be enabled.
sudo apt-get update
sudo apt-get install mysql-client -y
Done. You can now run the new MySQL client and connect with the new authentication method.
The below solution worked for me
Go to Mysql Workbench -> Server-> Users and Privileges
1.Click Add Account
2.Under Login Tab provide new details and make sure to choose the Authentication Type as standard and choose respective administrative roles and Schema Privileges
Actually MySql allows two type of authentication at the time of installation.
Password Encryption
Legacy Encryption
Read Here
So by checking legacy authentication the issue was resolved.
Try using legacy password while downloading and installing MySql, that helped me.
Or follow the method posted by Santhosh Shivan for Mac OS.
Just downloaded the latest mysqlworkbench which is compatible with the latest encryption:
https://downloads.mysql.com/archives/workbench/
Note: On Mac big Sur, the latest two versions: 8.0.22 and 8.0.23 are buggy and do not work.
Use 8.0.21 until these are fixed
I run docker in M1 (arm64), the direct way of changing in the docker bash does not work for me. Instead, I change the mysql image to be
mysql:8.0.26
and the platform is set as
linux/x86_64
and add default_authentication_plugin=mysql_native_password to my.cnf
Then, you rebuild your container.

How to reset MySQL root password using xampp/phpmyadmin? [duplicate]

I have a little problem with my phpmyadmin, in fact I accidentally delete multiple user accounts.
Since it is impossible to connect without the error:
# 1045 - Access denied for user 'root' # 'localhost' (using password: NO)
I have search a little on the net before, and even the technic:
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
does not work, or I didn't understood how it worked.
I'm on FreeBSD 8.1, my version of PhpMyadmin is 2.11.
Thank you in advance for your answers.
I summarised my solution here: http://snippets.dzone.com/posts/show/13267
sudo stop mysql
sudo mysqld --skip-grant-tables --skip-networking
mysql
mysql> update mysql.user set password = password('your_new_password') where user = 'root';
mysql> flush privileges;
mysql> exit;
sudo mysqladmin shutdown
sudo start mysql
For mysql 5.7.16 or later I found this (from mysql.com) to be the working solution. Below are some points which are different compared to previous older versions
1) I used the below command to run mysql in safe mode as per some other references which actually worked fine for me (mysql 5.7.16 ubuntu 16.04).
mysqld_safe --skip-grant-tables --skip-networking
2) The below update stmt is NOT working for later version (ie. 5.7 and above)
-- NOT Working for 5.7 and later
UPDATE mysql.user SET Password = PASSWORD ('') WHERE User = 'root';
FLUSH PRIVILEGES;
INSTEAD use below for 5.7.6 and later
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
OR user below for 5.7.5 or earlier versions.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
I am Using MySQL Server 8 and this is how I solved this problem.
create a file and name it accordingly. I've named it as reset.txt. put below content in the file but change MyNewPass. This will be your new SQL password
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
Stop my SQL server (Go to services and search MYSQL and right-click on it and stop )
Now open a cmd in your bin folder of My SQLserver directory. in my case it's
C:\Program Files\MySQL\MySQL Server 8.0\bin
execute the following command.
mysqld.exe --defaults-file="C:\ProgramData\MySQL\MySQL Server 8.0\my.ini" --init-file="C:\reset.txt'
NOTE: my reset.txt file is in the c drive. Give the correct path. Check my.ini file is in the directory. In my case, it is in
C:\ProgramData\MySQL\MySQL Server 8.0\my.ini
Finally, restart the SQL Server. Check with your new password.
Please follow the instruction from the below link to reset your root password.You have to do it from outside mysql.
Resetting MySql Password
Forgetting your MySQL password can be a real headache for you.Here are some easy steps that you can follow to recover MySql password under Windows
Stop MySql
You have to stop MySql service before you proceed.In Windows environment, go to 'Task Manager' and Under 'Service' tab find MySQL and stop it.
Write Sql to change your password
All you need to do is to create a text file and put the below two lines into that. UPDATE mysql.user SET Password=PASSWORD('MyNewPass') WHERE User='root'; FLUSH PRIVILEGES; Save it under C:\ drive and give it a name 'mysql-init.txt'
Time to restart MySQL by your own.
Now it's time to restart your MySQl which you stopped in before but this time from command line. C:> C:\mysql\bin\mysqld-nt --init-file=C:\mysql-init.txt
Finishing up!
Now you can log in with your new password. When you finish remove the file that you created in the previous stage.
Also there is a link (http://kaziprogrammingblog.osinweb.com/article/showarticle/Resetting-MySql-Password) where I have explained the same thing.
Hope this will help..:)
Answer for XAMPP on Windows:
Edit C:\xampp\mysql\bin\my.ini and insert skip-grant-tables below [mysqld]
Restart MySQL from Control Panel interface
In the phpMyAdmin window, select SQL tab from the top panel. This will open the SQL tab where we can run the SQL queries. Now type the following query in the text area and click Go
UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root'; FLUSH PRIVILEGES;
Remove the skip-grant-tables in the my.ini file
Restart MySQL from Control Panel interface
DONE!
Be awared that mysql root user password does not have to be the same as password for phpmyadmin.
here is what I did and it worked:
After you install (rpm installation), do a vi /etc/my.cnf.
This will give you a path where your datadir is set. For me it was datadir=/var/lib/mysql.
Add a line there user=root, and remove all the content inside the datadir path: rm -rf /var/lib/mysql/*.
Now hit the command: mysqld --initialize.
A temporary password is generated at a location. For this:
grep "A temporary password" /var/log/*.
You will get a line that says:
/var/log/mysqld.log:2018-05-01T15:13:47.937449Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root#localhost: &uosjoGfi9:K. So for me &uosjoGfi9:K was my temporary password.
Now do a mysql -u root -p. Paste your temporary password from what you got from above.
You will be in your mysql cli mode. Now do:
mysql> use mysql;
You will be asked to reset your password:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
Run your ALTER command:
mysql> ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPswd';
And you are done.
in my case its a frustrating Windows Server installation (iis/php/mysql) so this is what i did:
PART 1: remove the old MYSQL :
NOTE: if you already have data you should back it up!
Step 1
Uninstall MySQL from Control Panel. (you should know how to do this)
Step 2
Run Command Prompt as Admini and execute the following commands to stop and remove MySQL service.
Net stop MySQL
Sc delete MySQL
Step 3
Delete these folders:
C:\Program Files\MySQL
C:\Program Files (x86)\MySQL
C:\ProgramData\MySQL
And if it exists:
C:\Users\[User-Name]\AppData\Roaming\MySQL
PART 2: Install MYSQL
Download installer from https://dev.mysql.com/downloads/installer/ and install
-MySQL Server 8.0.23
open cmd as admin and go to
c:\Program Files\MySQL\MySQL Server 8.0\bin\
run
mysqld --initialize --console
mysqld --install
now start the service (type services.msc in run panel)
now back to console run:
mysql -u root -p
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyNewPass';
that's it
mysql80:
update user SET authentication_string='your password after encode to sha256' where User='root';

Unable to access MySQL after it automatically generated a temporary password

I have erased and installed OSX 10.11 El Capitan and I have been following through this tutorial to get MySQL up and running on the new OS X. The first step was to download MySQL For Mac OS X 10.9 (x86, 64-bit), DMG Archive (works on 10.11, they recommended in the tutorial). While I were finishing installing the MySQL, I got the message saying that :
2015-10-25T02:10:54.549219Z 1 [Note] A temporary password is generated for root#localhost: R>gFySuiu23U
If you lose this password, please consult the section How to Reset the Root Password in the MySQL reference manual.
That was weird, I have never seen that kind of message. After that, I started MySQL via the Preference Pane and then use /usr/local/mysql/bin/mysql -v command on the terminal for another step. I got an error message saying that :
ERROR 1045 (28000): Access denied for user 'cheetah'#'localhost' (using password: NO)
I have also tried to access database through Sequel Pro using root as username and blank password, I got access denied message saying that :
Unable to connect to host 127.0.0.1 because access was denied.
Double-check your username and password and ensure that access from your current location is permitted.
MySQL said: Access denied for user 'root'#'localhost' (using password: NO)
Okay, I also tried this again using root as a username but 'R>gFySuiu23U' as a password (which was generated from MySQL). I got connection failed message saying that :
Unable to connect to host 127.0.0.1, or the request timed out.
Be sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently 10 seconds).
MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.
How could I solve this problem? I remember that MySQL has never got automatically generated a temporary password like this, hasn't it ?
Try this:
mysql -u root -h 127.0.0.1 -p
Enter password: (enter the random password here)
Ref:https://dev.mysql.com/doc/refman/5.7/en/data-directory-initialization-mysqld.html
Following this, you may reset your password using
ALTER USER 'root'#'localhost' IDENTIFIED BY 'new-password';
This is what worked for me on OS X Yosemite running MySql v5.7 (installed from the .dmg).
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
(Enter the temporary password generated by the installer.)
This gets you into sandbox mode and mysql> prompt. Then set desired root password with SET PASSWORD:
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('mySuperSecretPassword');
Now that the password MySQL had generated is expired, the problem is reduced to getting this password to work again (1) or generate a new one (2). This can be accomplished by running MySQL with the skip-grant-tables option which would make it ignore the access rights:
Stop your MySQL server.
Add the below at the end of the [mysqld] section of my.cnf file and save it.
skip-grant-tables
Start MySQL server.
In terminal, type
mysql -u root -p
to get into MySQL command prompt.
In the command prompt, type
USE mysql;
to get into the mysql database where it keeps database users.
Type
UPDATE user SET password_expired = 'N' WHERE User = 'root';
to let MySQL know the password is not expired (1) or
UPDATE user SET authentication_string = PASSWORD('YourNewPassword'), password_expired = 'N' WHERE User = 'root';
to assign a new password YourNewPassword to root (2).
Doing these steps under OSX 10.11 El Capitan and MySQL 5.7.X, should do the trick.
Considering that you already have MySQL installed then..
Open a terminal window and type:
sudo /usr/local/mysql/support-files/mysql.server stop
sudo mysqld_safe --skip-grant-tables
Since the command fired in the step 2 will be under on going state, you need to open another terminal window and then type:
mysql -u root -p
UPDATE mysql.user SET password_expired='N', authentication_string=PASSWORD('') WHERE User='root';
quit;
sudo /usr/local/mysql/support-files/mysql.server restart
Important: in the step 2 you must replace for your password.
Hope it will wok for you.
MySQL password expired
Resetting the password will solve the problem temporarily, however, from MySQL 5.7.4 to 5.7.10 (I think to encourage better security) the default value for the default_password_lifetime variable is 360 (about a year). For those versions, if you make no changes to this variable (or to individual user accounts) all user passwords expire after 360 days.
Typically, from a script you might get the message: "Your password has expired. To log in you must change it using a client that supports expired passwords."
So, to prevent automatic password expiry, log in as root (mysql -u root -p), then, for clients that automatically connect to the server (e.g. scripts.) change the password expiration settings for those clients:
ALTER USER 'script'#'localhost' PASSWORD EXPIRE NEVER;
or you can disable automatic password expiration for all users:
SET GLOBAL default_password_lifetime = 0;
Links:
MySQL: Password Expiration and Sandbox Mode
MySQL: Password Expiration Policy
Password expiration policy in MySQL Server 5.7
I'm running macOS Sierra(10.12.3) and I installed mysql-5.7.17-macos10.12-x86_64.dmg.
The answer from #lesley worked for me with the exception that I needed to add ./ to ensure I was calling the mysql binary in my current working directory. Which is where the aforementioned package was installed.
If you cd to /usr/local/mysql/bin and run mysql -u root -p --connect-expired-password, you could receive the following error.
mysql: unknown option '--connect-expired-password'
I did. Because simply running mysql without providing a path, called a previously installed version of the MariaDB client.
So to ensure you are executing the correct binary, you can either
provide the absolute path
/usr/local/mysql/bin/mysql -u root -p --connect-expired-password
or the relative path after changing directories
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
Both ways should work. Once you are connected to the client, the instruction are the same as above from #lesley.
Enter your temporary password generated by the installer and set your new password.
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('yourNewPassword');
I faced the same problem. I followed the installation process guide from https://www.ntu.edu.sg/home/ehchua/programming/sql/MySQL_HowTo.html and downloaded DMG archive and installed MySQL on my MAC OS X 10.12.2.
Finally executed the following commands on new Terminal.
cd /usr/local/mysql/bin
./mysql -u root -p --connect-expired-password
It worked.
Answer 7 worked for me: El capitan, MySQL installed from dmg and autogenerated password, but made sure to cd to /usr/local/bin/mysql before entering ./mysql -root -p Obvious, but I didn't the first time.
Now to find where all my databases and tables are and how to link them in.
For Mysql 5.7 I use
shell $ > sudo grep 'temporary password' /var/log/mysqld.log
This particular one did the trick for me:
As specified in this link: https://www.variphy.com/kb/mac-os-x-reset-mysql-root-password
Do all the steps except executing
UPDATE mysql.user SET Password=PASSWORD('NewPassword') WHERE User='root';
Execute
UPDATE mysql.user
SET authentication_string = PASSWORD('MyNewPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
And then execute
FLUSH PRIVILEGES;
The another way to solve this issue is to use an older version of MySQL instead.
I have uninstalled MySQL version 5.7.9 for Mac OS X 10.9 (x86, 64-bit), DMG Archive and then install the older version, MySQL version 5.6.7 for Mac OS X 10.9 (x86, 64-bit), DMG Archive. This issue is solved. The given autogenerated password before finishing installation of this older version is gone and I can ultimately access the database using root as username and a blank password. Everything is working like a charm!
I installed view brew, and I had the same error message until I noticed this caveat:
We've installed your MySQL database without a root password. To secure it run:
mysql_secure_installation
To connect run:
mysql -uroot
To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don't want/need a background service you can just run:
mysql.server start
I got around this problem by running
'mysql -u root -p --connect-expired-password'
Then input the expired auto-gen password from mysql. Finally got in. Selected mysql db with
'use mysql'
and then updated user 'root' pw with
'ALTER USER 'root'#'localhost' IDENTIFIED BY 'your new password'
Installing MySQL manually by downloading packages for the first time generates a default password for root. Copy and save that. If not done somehow on successive re-installations it does not show that password.
Thus you cannot login to root.
Do the following :
Find mysql related entries from system
sudo find / -name mysql
Remove all mysql related entries by doing rm -rf <mysql_entries_above>
Download latest mysql-server and intall it.
You will be promted with a default password which you need to copy.
Run mysql_secure_installation and paste that password when asked for root.
Subsequently follow the steps and change admin password when prompted for.
Restarting Mysql server worked for me.
But in Mysql80-Server, it is more complicated than 5.7. In MySQL80 not allow you to update or change password during the config in my.cnf in state "skip grant table". So you need 3 big steps to do
I) change my.cnf to skip-grant-table
II) login MySQL with blank password & update table to blank password
III) restart mysql and login with blank password and update to new password
Step to do: (whatever, you forgot root password, temporary password gen by installation not work, etc. please follow the steps below) In my case on FreeBSD 12.2
stop your mysql server by
/usr/local/etc/rc.d/mysql-server stop
recheck again whether it is really stop (in case more serious problem than that)
/usr/local/etc/rc.d/mysql-server status
mysql is not running.
find your my.cnf file and add "skip-grant-tables" to it.
(normally before [Mysqldump] head)
restart mysql
/usr/local/etc/rc.d/mysql-server start
login to mysql
mysql -u root -p
when it ask for password, just press enter and you will log into mysql
select DB to use
use mysql
look at the table user
select user, authentication_string,password_expired from user;
update to blank password
UPDATE user SET authentication_string = '', password_expired='N' WHERE User = 'root';
quit mysql and make mysql stop
goto file my.cnf then take "skip-grant-tables" out of file.
restart mysql again with "mysql -u root -p" enter the blank password
then
ALTER USER 'root'#'localhost' IDENTIFIED WITH
caching_sha2_password BY 'YourNewPassword';
quit mysql and make mysql stop
restart mysql again then you will login with your new password
This may happens when you have installed mysql before.
Try the password you set for the last version of mysql.
This did work for me.