MySQL Error: Authentication plugin 'caching_sha2_password' cannot be loaded - mysql

I just installed MySQL Ver 14.14 Distrib 5.7.22 with Homebrew on my macOS v10.13.4.
I ran the command:
brew install mysql
After the installation completed, as directed by Homebrew, I ran the command:
mysql_secure_installation
and was returned the error: Error: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found
I tried a few things like changing default_authentication_plugin to mysql_native_password in the my.cnf file but it still throws the same error.
Next I tried running:
mysql_upgrade -u root
and I was thrown the same error again mysql_upgrade: Got error: 2059: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/Cellar/mysql/5.7.22/lib/plugin/caching_sha2_password.so, 2): image not found while connecting to the MySQL server
Upgrade process encountered error and will not continue.
Any help is appreciated.

So, I found the running process of mysqld by sudo lsof -i tcp:3306 then I killed it using sudo kill -9 <PID>.
After this I tried mysql_secure_installation again, but ran into a new error :
Error: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (61)
After trying a few fixes for getting mysql.sock to work, I started the MySQL server with sudo mysql.server start then went ahead with mysql_secure_installation to set password for the root user.
This worked for me finally.
Note: Homebrew asks you to first do mysql_secure_installation before starting the MySQL server for the first time but that just made me run into endless loop of errors.

Restart the mysql server to take the changes in affect and try connecting via mysql with any mysql client.
Otherwise use docker
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
Related a question.
Authentication plugin 'caching_sha2_password' cannot be loaded

I figured out this should be an issue with the mysql version installed. Just as above you should first find then kill the mysqld process attached on port 3306
sudo lsof -i tcp:3306
sudo kill -9 <Peocess ID>
Then upgrade the mysql installation via brew, in this case:
brew upgrade mysql
This should solve it.Running mysql after the upgrade should start your server after the installation.
e.g mysql -u root -p [your password here]

I got this error in Sequel Pro trying to connect over SSH to an AWS Ubuntu server with MySQL installed locally.
I was using a non-root MySQL user and it gave me that error. It worked when I ran it with the root user and password.

Related

Can't connect to MySQL installed via Homebrew on Mac Monterey

I ma using M1 MacBook Air, and managing my tools with Homebrew.
I've installed Mysql, and it was working fine for a while, but when I've rebooted my device it just stopped working.
I don't get any errors when running brew services start mysql, but when I try brew services list MySQL is marked as stopped.
When I try to enter mysql with mysql -u user -p password I get following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
When I run mysql.server start (as some answers suggest) I get following error:
. ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/MacBook-Air.local.pid).
I've tried many solutions, but non of them worked.
i fixed this error The server quit without updating PID on mysql version 8.0.18
try sudo chown -R mysql:mysql xx/mysql, and sudo chmod 775 xx/mysql
'xx/mysql' is your mysql home dir

Warning: mysql_connect(): Can't connect to local MySQL server through socket

My WordPress site ( http://steamboatperinatalconference.com ) just recently started going down and spitting this error
" Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /var/www/html/wp-includes/wp-db.php on line 1568 "
I have checked the db password and its ok, also reset the instance and sql server and both are running, I'm able to connect to my database through mysqlworkbench.
Not sure why my website won't display if the database is up and running.
Any help is appreciated.
First kill the processes with:
sudo pkill mysql
and
sudo pkill mysqld
restart mysql
sudo service mysql restart
now you should be able to log in
mysql -u root -p
It turns out in order to fix the issue I was having I needed to run a sudo yum update on the AWS ec2 instance, after performing the update the page was back up and running
my.cnf (location of file /etc/mysql/ folder) configured with
socket=/var/lib/mysql/mysql.sock
check for MySQL is running with the following command:
mysqladmin -u root -p status
changing permission to MySQL folder. If you are working locally, you can try:
sudo chmod -R 755 /var/lib/mysql/

Resetting MySQL password & missing mysqld.sock file

I am trying to run a local mysql server, on my own computer. I have lost the password that I initially set up. When I try to connect to mysql, I get the following error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I have therefore tried these steps to reset my MySQL password, but the line
mysql -u root mysql
returns the same error message:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
When running the command
mysqladmin -u root -p status
I get the following message:
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/var/run/mysqld/mysqld.sock' exists!
I have been checking and the file mentioned (/var/run/mysqld/mysqld.sock) doesn't actually exist. I am not sure what is causing this.
I have tried a couple of solutions online including this, this, this and this but none of this solutions worked for me. I would like to add that mysql-server is installed on my machine.
Any help appreciated. Please accept my apologies if there is any confusion to the above statements. I tried to explain what is happening as much as I can, but I am a beginner and I am clueless as to what is happenening there.
1) Stop the mysql demon process using this command :
sudo /etc/init.d/mysql stop
2) Start the mysqld demon process using the --skip-grant-tables option with this command
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
Because you are not checking user privs at this point, it's safest to
disable networking. In Dapper, /usr/bin/mysqld... did not work.
However, mysqld --skip-grant-tables did.
1) start the mysql client process using this command
mysql -u root
2) from the mysql prompt execute this command to be able to change any password
FLUSH PRIVILEGES;
3) Then reset/update your password
SET PASSWORD FOR root#'localhost' = PASSWORD('password');
4) If you have a mysql root account that can connect from everywhere, you should also do:
UPDATE mysql.user SET Password=PASSWORD('newpwd') WHERE User='root';
once have received a message indicating a successful query (one or more rows affected), flush privileges:
FLUSH PRIVILEGES;
Then stop the mysqld process and relaunch it with the classical way:
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql start
This is borrowed from https://help.ubuntu.com/community/MysqlPasswordReset , you can check also another method to reset mysql password.
Looks like your MySQL server is not running at all.
Can you check it?
service mysql status
You need to try restart it and make sure that you can stop and start it using
service mysql stop
service mysql start
If you have any errors post them here please.
Reinstalling mysql-server worked for me. (I am using mysql 5.7)
sudo wget http://repo.mysql.com/mysql-apt-config_0.8.9-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.9-1_all.deb
sudo apt-get update
sudo apt-get install mysql-server
mysql_secure_installation
first kill user
sudo pkill -u <user>
Then install mysql server
sudo apt install mysql-server
Configure it
sudo mysql_secure_installation
Enter into mysql shell
sudo mysql

Can not connect to mysql server (Percona)

I have installed percona server version 5.7 on my centos 7.Now when I try to issue following command to connect to the server.
access denied for user 'root'#'localhost'
I have tried to use the --skip-greant-tables to change the password and host from localhost to %.
I have tried changing the OS hostname to localhost.
I have also tried using --skip-name-resolve.
but still no chance.
any help appreciated
In Percona 5.7, the temporary password is stored in /var/log/mysqld.log so you can find it by:
grep 'temporary password' /var/log/mysqld.log
After that, you can start mysql
sudo systemctl start mysql
sudo /usr/bin/mysql_secure_installation
and use your temporary password to use.
After installing percona, you have to run these commands in order to set password for user root on mysql :
1- sudo systemctl start mysql
2- sudo mysql_secure_installation

Installing xampp but phpmyadmin doesn't connect

So I installed xampp on my Linux machine running Ubuntu 14.04LTS. Now all of a sudden turns out when I try to connect to phpmyadmin it refuses to connect. I have already installed mysql separately as well but it doesn't seem to work. Any workaround for this?
The error that I get is :
MySQL said:
Cannot connect: invalid settings.
Connection for controluser as defined in your configuration failed.
phpMyAdmin tried to connect to the MySQL server, and the server rejected the connection. You should check the host, username and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server.
Any reason why this happens and solution to it?
Go to http://localhost/security/ and then click on the link http://localhost/security/xamppsecurity.php.
After that change password for superuser to 'root'.
After that open your http://localhost/phpmyadmin/
As per the comment by RiggsFolly I was running two instances of MySQL
So both mysql servers do end up messing with phpmyadmin and this is how you shutdown the external mysql server while using xampp's inbuilt mysql server to connect successfully using phpmyadmin:
Use whichmysql to find the utility that is running
Navigate to the directory where the external MySQL service is running:
$ cd /usr/bin
$ mysqladmin shutdown
This shuts down the MySQL service running if at all it is running.
$ sudo service mysql stop
This helps as well if at all it will tell you the status of the service if it is already shut down.
Now we need to stop the Xampp mysql server so we navigate to /lampp/bin and again execute the same command to shut mysql server down.
$ cd /opt/lampp/bin
$ mysqladmin shutdown
Simply restart xampp and you should be good to go.
$ sudo /opt/lampp/lampp restart
I just fell into the same error. The solution I used was, stopping all the servers of xampp, exiting the program. Starting and stoping mysql then starting xampp again
Initial procedure before starting xampp:
sudo service mysql stop
sudo /etc/init.d/apache2 stop
If it bring the error as stated in this question, then follow the procedure below.
That is:
sudo /opt/lampp/lampp stop
sudo service mysql start
sudo service mysql stop
sudo /opt/lampp/lampp start