How to reset MySQL root user password and privileges - mysql

I assigned a password to the root MySQL user in XAMPP some times ago. I recently tried to undo that and give it no password but it's not working.
I tried setting the password to an empty string using mysqld --skip-grant-tables and then using the mysql command line directly. It looks like it works, the root user no longer has a password, however if I login in PhpMyAdmin I cannot see any of my databases, only an "information_schema" and a "test" database. If I look at the User tab, it seems to have all the privileges though:
Any suggestion on how to fix this issue?
Note: I checked with the command line, all my databases and tables are still there, I just cannot see them in PHPMyAdmin.

Try removing the anonymous user who is allowed to connect from any host. My feeling is that that row is taking precidence over the row for root when MySQL validates the login.
If you have removed that Anonymous user and the issue still occurs, try setting a password to root and the host to localhost then connect again.

Related

Access denied for user error during install phpmyadmin

I want to install phpmyadmin on Ubuntu 20.04. I take the password 2 times (first I tryed root password but after I tryed leave the field empty or use other password). Any time I error like screen of my error. I found this tutorial.
Author of this article wrote:
From the prompt, run the following command to disable the Validate
Password component. Note that this won’t actually uninstall it, but
just stop the component from being loaded on your MySQL server:
But this component is disable and yet I still have this error. How can I solve my problem
The error message you posted is different from the Validate Password one in the tutorial. I suggest re-enabling the option that you disabled.
Your error is showing that you (or someone) has changed the password of the MySQL user that Ubuntu (and Debian) uses for administrative purposes (debian-sys-maint). Details of that user are documented in README.Debian and the password is stored on disk in /etc/mysql/debian.cnf.
To resolve this, you can simply set the password to a known value and edit the configuration file to tell your system the new password.
Presumably, you're using MySQL 8.0.20, in which case you would connect through the command line client (mysql -u root -p) and run a command like this: ALTER USER 'debian-sys-maint'#'localhost' IDENTIFIED BY 'aReallyComplexPassword';.
On the chance that you're using MariaDB, the command is SET PASSWORD FOR 'root'#'localhost' = PASSWORD('aReallyComplexPassword');.
You won't need the password again after you put it in /etc/mysql/debian.cnf). Note that you'll need to edit the debian.cnf file as root or sudo.

Can't connect to MySQL using SequelPro

I have recently installed MySQL 5.7.16 on an iMac running El Capitan. I had a few minor hiccups initially because I forgot the root password but that has now been reset and I can now log into MySQL as root user using:
$ mysql -u root -p
However, when I try to connect to MySQL server as root using SequelPro, I get the message:
Unable to connect via the socket, or the request timed out.
Double-check that the socket path is correct and that you have the necessary privileges, and that the server is running.
MySQL said: Your password has expired. To log in you must change it using a client that supports expired passwords.
When I look in /tmp folder, I was expecting to find mysql.sock but, instead, there is a file called mysql.sock.lock. Could this be causing the problem? I can't find where that .lock file has come from and I'm not sure what to do about it. Any help would be appreciated.
I'm not entirely sure what happened to cause the root password to expire but something had thrown a spanner in the works. Anyway, the solution for me was to log into MySQL from the Terminal using:
$ mysql -u root -p
...and then alter the root user's password using:
> ALTER USER 'root'#'localhost' IDENTIFIED BY 'NewPass';
That seemed to do the trick. I was then able to log in to MySQL using Sequel Pro with no problems.
Instead of using a socket connection, you could try connecting via Sequel Pro's standard connection using 127.0.0.1 as the host.
Thus spake the 5.7 docs:
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 assign a new password. (The server writes the random password to the error log.)
So, connect from terminal and change the root password.
Either your first password may not have been saved OR it just truly never persisted.
For me it was the sudo /usr/local/bin/mysql_secure_installation that may not have ever persisted the password correctly. Since your first password never changed, there is no password or ,like your error said, "expired" to nothing.
Run or rerun the code above, don't type anything for the password field and follow the steps, from the preloaded setup program.

MySQL server root user deleted, can't connect to server

Somehow I must have deleted the root user and now I am getting messsages that localhost cannot connect to the server so I pretty much can't do anything at the moment. I tried to reinstall the server but for some reason there is no root account created.
Is there some kind of hidden file on my computer that is disallowing connections from localhost despite me completely removing the server application?
Some have suggested using --skip-grant-tables and adding a root user but I just get a message that localhost can't connect to the server. It's madness, can't I just create another server instance with a root account or something?
You can create the root user using the method described in section C.5.4.1.1
http://dev.mysql.com/doc/refman/5.5/en/resetting-permissions.html
However, instead of an update of the password put the following SQL in the text file:
use mysql;
insert into user (Host, User, Password) values ('localhost','root','');
update user set Select_priv='Y',Insert_priv='Y',Update_priv='Y',Delete_priv='Y',Create_priv='Y',Drop_priv='Y',Reload_priv='Y',Shutdown_priv='Y',Process_priv='Y',File_priv='Y',Grant_priv='Y',References_priv='Y',Index_priv='Y',Alter_priv='Y',Show_db_priv='Y',Super_priv='Y',Create_tmp_table_priv='Y',Lock_tables_priv='Y',Execute_priv='Y',Repl_slave_priv='Y',Repl_client_priv='Y',Create_view_priv='Y',Show_view_priv='Y',Create_routine_priv='Y',Alter_routine_priv='Y',Create_user_priv='Y' where user='root';
flush privileges;

MySQL workbench - Can't connect to a specific database

I'm facing a strange issue here and it seems impossible to me to connect to my MySQL database.
I have used the workbench few times ago, but it was an older version. The problem with the new one (6CE) is that I can't connect directly to a database - it only allows me to create a connection to the server as a root user and I don't remember this password.
Is there a way to make a connection directly to the dataase itself as in the previous versions, or now only the root is an option. If yes I will have to reset my password.
Make sure that your credentials are still valid, and has proper privileges. If you can log into your mysql-server from terminal (with root account or the user you are trying with), then run "SHOW GRANTS" and see the privileges;
To connect to mysql database you need to have your user account's hostname specific to your IP or wildcard (%).
Similarly you can create a new mysql user with the following command from your server, and then try with this new user.
GRANT ALL ON <db>.* TO 'user'#'<ip or %>' IDENTIFIED BY '<password>' ;
FLUSH PRIVILEGES;
Be careful with the user created above. It will have ALL privilege with the specific database. And using % is actually a bad idea, so user you home machines IP (from where you are trying to connect with Workbench)

Phpmyadmin - Mysql no privileges

I installed wamp 2.1 on windows 7. However when i open phpMyAdmin, I get the error, Mysql 'No Provileges'. I uninstalled wamp and reinstalled it a few times, but it doesn't help. Does anyone know how to solve this issue?
Also, when i tried creating a database from mysql console, i am getting the following error:
ERROR 1044 <42000>: Access denied for user ''#'localhost' to database 'a_db_name'
Thank God and to all helped.
Its simple.
Must! click logout icon in phpadmin page
In login page, type:
username:root password: (blank)
surprise. now you can happily create your database.
Are you logging into MySQL as root? You have to explicitly grant privileges to your "regular" MySQL user account while logged in as MySQL root.
First set up a root account for your MySQL database.
In the terminal type:
mysqladmin -u root password 'password'
To log into MySQL, use this:
mysql -u root -p
Edit:
To set the privileges manually start the server with the skip-grant-tables option, open mysql client and manually update the mysql.user table and/or the mysql.db tables. This can be a tedious task though so if what you need is an account with all privs I would do the following.
Start the server with the skip-grant-tables option
Start mysql client (without a username/password)
Issue the command
flush privileges;
which forces the grant tables to be loaded.
Create a new account with the GRANT command something like this (but replacing username and password with whatever you want to use.
GRANT ALL on *.* to 'username'#'localhost' identified by 'password';
Restart the server in normal mode (without skip-grant-tables) and log in with your newly created account.
Refer this MySQL docs.
Take a look at my topic regarding this issue, which takes some of the above.
MAMP mysql broken root user
You need to shutdown your mysql install and restart it from the command line properly like is indicated above. In my topic I have full clear instructions on how to do so. My instructions are for MAMP but you should be able to adapt it for your install.
Simple solution. Just find the icon right to "home" in PhpMyAdmin and click to logout. Then login using username "root" and password ""(blank). This will work accordingly.
username ought to be root and keep the password null(keep the password field blank)
right click on the wamp icon and goto mysql console.
Login with password if you have set any.By default the password is blank and username is 'root'
Once you are in mysql prompt execute
FLUSH PRIVILEGES;
now quit the command prompt and you are good to go.
in step 1 .inter your databasevery important.
in step 2 .select your database via all tables .
in step 3. backup type=replace & export.
in step 4 import database in my sql.
attention please:in import your database...
all table must view & selected in step 4.