Error after uploading laravel project from local to web server - mysql

I uploaded a laravel project from local to web server. After uploading I get following error:
SQLSTATE[HY000] [1275] Server is running in --secure-auth mode, but 'root'#'127.0.0.1' has a password in the old format; please change the password to the new format (SQL: select * from `video_categories`)

As of MySQL version 4.1, the way in which user passwords are stored was changed for greater security. By default, the server will still allow users with passwords stored in the old format to connect for backwards compatibility. However, if the server is running with the --secure-auth parameter or the secure-auth option specified in the [mysqld] section of it's option file, users that have a password stored in this old format will not be allowed to connect.
To allow the user to connect, you can either disable secure-auth mode by removing the option/parameter and restarting the server or reset the user's password with the new format. The problem with resetting the user's password is that if you do not know the existing password you will have to change it.
To reset the password, run the following command on the server in mysql:
SET PASSWORD FOR 'root'#'127.0.0.1' = PASSWORD('password');

Related

Is there any way to get my WP database if I've lost access to root on mysql?

Few minutes ago I've done very unecessary move. I wanted to change password to root on my localhost server (I'm using WAMP any my MYSQL version is 5.7.21) and I picked the "SHA-256" option, now I have these errors in my PHPMyAdmin Panel:
#2054 - The server requested authentication method unknown to the client
mysqli_real_connect(): The server requested authentication method unknown to the client [sha256_password]
mysqli_real_connect(): (HY000/2054): The server requested authentication method unknown to the client
I've had an wordpress database on my local server and mainly everything that I want is just to recover it, or also change the root password to do anything... I've read some questions there and the method with changing
default-authentication_plugin = mysql_native_password
in "my.ini" isn't working for me. I tried to run init file with
SET PASSWORD FOR 'root'#'localhost' = PASSWORD('MyNewPass');
and it's not working too. Is there any other way to change my password or only recover my wp database from it?

mysql can be connect locally but only remotely

I have a tomcat 8 webserver and try to connect local mysql 5.7, but having following error:
Caused by:
SQLNestedException: Cannot create PoolableConnectionFactory (Client does not support authentication protocol requested by server
I googled and people suggested to update the password and I did as well, however doesn't work for me.
What I did
ALTER USER 'root'#'localhost' IDENTIFIED WITH mysql_native_password BY 'password'
flush privileges;
Currently I can only use public ip address to connect back to the local database....
MYSQL changed the password storage method starting with version 4.1. If your client is trying to connect with the old way and the server has the password stored in the new way, then you will get that error message. In order to fix that, you have 2 choices:
check the settings on your tomcat server
change the password hash in the mysql server, to be compatible with versions pre-4.1
If you want to change the password to use the old hashing type, use a command like:
mysql> SET PASSWORD FOR
-> 'some_user'#'some_host' = OLD_PASSWORD('new_password');
After that you have to start your mysql server with old_passwords system variable set to 1
On the other hand, I think that the best way of resolving this will be to set the client to use the proper way of connecting to the mysql server.
If you use PHP for connecting to the server, check if you use mysql of mysqli library. I think that only mysqli library uses the new way of managing connections.

Cannot login to phpMyAdmin error #1862 - Your password has expired

I installed MySQL, PHP, and phpMyAdmin following this tutorial. Everything works well, i.e., I can start and connect to MySQL through the command line without any error, but the problem is when I try to login to phpMyAdmin, I receive this error:
#1862 - Your password has expired. To log in you must change it using a
client that supports expired passwords.
It might worth saying that my current MySQL password is not the temporary one that I received when I installed MySQL, but I changed it later (before installing phpMyAdmin), and now trying to login to phpMyAdmin with this new (current) password shows me the above error.
What might be the problem?
Ok, finally I did not understand what was the reason for this issue, but the following solution worked for me:
Enter this in terminal (in /usr/local/mysql/bin/) mysqladmin -u root -p password
Enter your password
Enter New password
Done! I could then login from phpmyadmin too!
Hope it help others who have similar problem,
MySQL password has expired
From MySQL 5.7.4 the default value for default_password_lifetime is 360 (a year). If you make no changes to this variable or individual user accounts, all user passwords expire after 360 days (so you get: "Your password has expired. To log in you must change it using a client that supports expired passwords").
To prevent automatic password expiry, log in as root (mysql -u root -p):
For clients that automatically connect to the server (e.g. from scripts.) change the password expiration settings:
ALTER USER 'script'#'localhost' PASSWORD EXPIRE NEVER;
or you can disable auto-password-expiry for all users:
SET GLOBAL default_password_lifetime = 0;
Links I used to understand and fix this
MySQL: Password Expiration and Sandbox Mode
MySQL: Password Expiration Policy
Password expiration policy in MySQL Server 5.7

How to restore mysql users

I dropped accidentally all the users exist in my mysql DB and when I refresh the admin page I had this error :
Error
MySQL said:
1130 - Host 'localhost' is not allowed to connect to this MySQL server 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.
How can I restore those users without losing my data ?
You just need to set an init file with the correct SQL to create/set a password for the root user, and then restart the server with the --init-file parameter.
Follow the directions here. Any SQL in the init file will be run, so you can create more users if you need to also.

Access denied to MySQL remote connection attempt using SSL

I've setup a MySQL server v5.5.41 for SSL and I'm to trying to connect it remotely. I've created the SSL certs, keys, created a user and granted privileges like this:
GRANT SELECT ON mydb.* TO 'myuser'#'xxx.xxx.xxx.xxx' require x509;
I've updated the my.cnf file on the server like:
ssl-ca = /etc/mysql/certs/ca.pem
ssl-cert = /etc/mysql/certs/server-cert.pem
ssl-key = /etc/mysql/certs/server-key.pem
I've done the same with the client pem files (and ca.pem), adding them to my.cnf (under the client section). I've also updated (Linux) /etc/apparmor.d/usr.sbin.mysqld since I'm putting my pem files in a new directory that I created (certs).
And it all works! Except when I repeat the process of creating client pem files and user/privileges for my local development machine. I've done everything exactly the same, but when I try to connect, I get:
ERROR 1045 (28000): Access denied for user 'testuser'#'xxx.xxx.xxx.xxx' (using password: YES)
I've created the testuser on the mysql server and granted privileges in exactly the same way as before (verified by querying the DB). The client pems and ca.pem are on the box, and the cnf file has been updated. I've restarted MySQL. The password I'm using to connect to the server is definitely correct.
The only thing I can think of that's different is when I was creating the client cert, I didn't know what to put in for the Common Name. In the other case, where it's working, that machine is a web server, so the Common Name I used is the domain. For my development machine, I just used what I got from running the hostname command for the Common Name. If this is the problem, what should the Common Name be?
The reason for the problem was because I accidentally put these lines:
ssl-cert = /etc/mysql/certs/client-cert.pem
ssl-key = /etc/mysql/certs/client-key.pem
...on my local development machine under the [mysqld_safe] section instead of the [client] section in my.cnf, so there's no inherent MySQL or SSL issue here (although if I hadn't written up this question it might have taken me a lot longer to discover that).