Whenever I try to login via SSH on my MySQL server, the 'root' user does not require me to provide a password.
I already tried the suggestion from this guide, however, I still have no luck.
UPDATE mysql.user
SET authentication_string = PASSWORD('MyPass'), password_expired = 'N'
WHERE User = 'root' AND Host = 'localhost';
FLUSH PRIVILEGES;
and
ALTER USER 'root'#'localhost' IDENTIFIED BY 'MyPass';
I manage my database using phpMyAdmin and when I checked my user groups, before it says that 'root' doesn't have a password but when I tried the codes above, it changed the password to 'Yes', but still allows me to login as root via ssh.
Another problem is I cannot login using the 'root' user in phpMyAdmin.
By the way, im using MySQL 5.7.21 for Debian9
Update 4/10:
Some googling lead me to threads that says later version of MySQL/phpMyAdmin does not allow root to login anymore, but a month ago I was able to do it, unfortunately I forgot the steps that I did..
Can you check if you have a .my.cnf file in your home folder or in /etc/mysql/ ?
It could contain root credentials.
Also can you print the complete contents of your users table? There might be another entry giving root permissions when connecting locally.
Related
When I'm logged into Linux as root (or sudo), I thought when I typed mysql that MySQL used the current username and password of the Linux user, however, when I try that, it just gives error ERROR 1045 (28000): Access denied for user 'root'#'localhost' (using password: NO). I don't want to disable requiring a password, I just want it passed from the current user if they're not specified (I've already disabled anonymous users too).
If you don't specify the username, MySQL on Linux uses the username of the calling process, but not the password belonging to that user.
The password of the caller is not available to applications on Linux, and I think this is for the best!
By default, MySQL authenticates against an internal table of users and passwords that has nothing to do with the operating system's passwd file. The fact that MySQL instances often have a user called 'root' is coincidence; the MySQL 'root' is not the same as the Linux 'root', and they can (and should) have different passwords.
If you want to avoid the requirement to type a password every time, you should save a default user/password in $HOME/.my.cnf:
[client]
user = scott
password = tiger
(I recommend against storing the superuser password in this file.)
In MySQL 5.6, they introduces a new feature to store login credentials more securely. See https://dev.mysql.com/doc/refman/5.6/en/mysql-config-editor.html
Turn on the option AllowNoPassword on file /etc/phpmyadmin/config.inc.php.
Edit the file config.inc.php, search and uncomment this line:
// $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;
if it's set to false make it true and restart the Mysql Service and you are good to go
Then you can access PhpMyAdmin/MySQl Console without password.
just put an alias in your .bashrc:
alias mysql="mysql -u root -pYourPassWord"
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;
I have been using MySQL successfully using the command line, and have created various databases (mostly for CMS).
I decided to try using phpMyAdmin which I saw mentioned in a book on Joomla!.
But when I click on Databases, I only see information_schema, phpMyAdmin, and test.
I want to be able to administer all of my databases (presumably giving appropriate credentials). Probably related is the fact that if I log into mysql as the phpmyadmin user and do a show databases; query, I see only those three databases.
Do I need some sort of a grant involving the show_db_priv (granting to the phpmyadmin user)? If that's it, what is the exact syntax for doing that? When I do a show grants for this user, I can see that show_db_priv is not one of them.
Login as MySQL root user in phpMyAdmin. If you're not able to login as root in-spite of providing correct password, then make sure that you have this line in your phpMyAdmin's config.inc.php and is set to true.
$cfg['Servers'][$i]['AllowRoot'] = true;
If you've not assigned password to MySQL root account, then default password is blank. In that case check that AllowNoPassword is set to true in phpMyAdmin's config.inc.php
$cfg['Servers'][$i]['AllowNoPassword'] = true;
Not sure if this answer is relevant, as I am using phpMyAdmin as part of WAMP on a single site machine. Still, it might help someone else running into the problem of phpMyAdmin not displaying existing databases.
After installing WAMP on a new machine (with phpMyAdmin 4.0.4), and using a php script of mine to create some databases, phpMyAdmin would only show the information_schema and test databases.
When I ran mysql from a command prompt, the databases were there, so wtf??
After some experimenting I discovered that adding the following line cured the problem:
$cfg['Servers'][$i]['auth_type'] = 'config';
Note that the config.inc.php already had
$cfg['Servers'][$i]['user'] = 'root';
$cfg['Servers'][$i]['AllowNoPassword'] = true;
$cfg['Servers'][$i]['AllowNoPasswordRoot'] = false;
$cfg['Servers'][$i]['password'] = 'mypwd';
Note: The auth_type parameter is discussed in http://wiki.phpmyadmin.net/pma/auth_types,
but I don't see any comment on failure to show user created databases.
More details:
Without the auth_type line, a SHOW GRANTS (from phpMyAdmin) yields:
GRANT USAGE ON . TO ''#'localhost' IDENTIFIED BY PASSWORD '*CF74EB88D030BC86A14151B7CE22C8808A19AA4B'
With the auth_type line, SHOW GRANTS yields:
GRANT ALL PRIVILEGES ON . TO 'root'#'localhost' IDENTIFIED BY PASSWORD '*CF74EB88D030BC86A14151B7CE22C8808A19AA4B' WITH GRANT OPTION
GRANT PROXY ON ''#'' TO 'root'#'localhost' WITH GRANT OPTION
The easy way:
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'#'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Those two lines will grant all privileges for the user phpmyadmin. You might need to restart mysql service.
If you didn't have a user named phpmyadmin in the first place, you can create it with the following:
CREATE USER 'phpmyadmin'#'localhost' IDENTIFIED BY 'your_secret_password';
This answer definitely exists somewhere else, but I can't find it to give it credit.
Unable to set password for a user using 3.5.2.2 - phpMyAdmin for 5.5.27 - MySQL. When trying to set the password while logged onto phpMyAdmin as the user, it pops up the following error:
#1133 - Can't find any matching row in the user table
When logged on as root, following password set successfully message pops up.
SET PASSWORD FOR 'user'#'%' = PASSWORD( '***' )
In either case, password does not set and stays as it currently is, blank.
I encountered this error using MySQL in a different context (not within phpMyAdmin). GRANT and SET PASSWORD commands failed on a particular existing user, who was listed in the mysql.user table. In my case, it was fixed by running
FLUSH PRIVILEGES;
The documentation for this command says
Reloads the privileges from the grant tables in the mysql database.
The server caches information in memory as a result of GRANT and CREATE USER statements.
This memory is not released by the corresponding REVOKE and DROP USER statements, so for
a server that executes many instances of the statements that cause caching, there will be
an increase in memory use. This cached memory can be freed with FLUSH PRIVILEGES.
Apparently the user table cache had reached an inconsistent state, causing this weird error message. More information is available here.
This error can occur if trying to grant privileges for a non-existing user.
It is not clear to me what MySQL considers a non-existing user. But I suspect MySQL considers a user to exist if it can be found by a name (column User) and a host (column Host) in the user table.
If trying to grant privileges to a user that can be found with his name (column User) but not by his name and host (columns User and Host), and not provide a password, then the error occurs.
For example, the following statement triggers the error:
grant all privileges on mydb.* to myuser#'xxx.xxx.xxx.xxx';
This is because, with no password being specified, MySQL cannot create a new user, and thus tries to find an existing user. But no user with the name myuser and the host xxx.xxx.xxx.xxx can be found in the user table.
Whereas providing a password, allows the statement to be executed successfully:
grant all privileges on mydb.* to myuser#'xxx.xxx.xxx.xxx' identified by 'mypassword';
Make sure to reuse the same password of that user you consider exists, if that new "MySQL user" is the same "application user".
Complete the operation by flushing the privileges:
flush privileges;
I encountered this issue, but in my case the password for the 'phpmyadmin' user did not match the contents of /etc/phpmyadmin/config-db.php
Once I updated the password for the 'phpmyadmin' user the error went away.
These are the steps I took:
Log in to mysql as root: mysql -uroot -pYOUR_ROOT_PASS
Change to the 'mysql' db: use mysql;
Update the password for the 'phpmyadmin' user:
UPDATE mysql.user SET Password=PASSWORD('YOUR_PASS_HERE') WHERE User='phpmyadmin' AND Host='localhost';
Flush privileges: FLUSH PRIVILEGES;
DONE!! It worked for me.
It turns out, the error is very vague indeed!
1) Password was setting while logged on as root, as it was updating the user/password field in the users table under MySql.
2) When logged on as user, password was in fact not changing and even though there was one specified in the users table in MySql, config.inc.php file allowed authentication without password.
Solution:
Change following value to false in the config.inc.php.
$cfg['Servers'][$i]['AllowNoPassword'] = true;
So that it reads
$cfg['Servers'][$i]['AllowNoPassword'] = false;
Change user's host from Any or % to localhost in MySql users table. This could easily be achieved via phpMyAdmin console.
These two changes allowed me to authenticate as user with it's password and disallowed authentication without password.
It also allowed user to change its password while logged on as user.
Seems all permissions and the rest was fixed with these two changes.
To expound on Stephane's answer.
I got this error when I tried to grant remote connections privileges of a particular database to a root user on MySQL server by running the command:
USE database_name;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%';
This gave an error:
ERROR 1133 (42000): Can't find any matching row in the user table
Here's how I fixed it:
First, confirm that your MySQL server allows for remote connections. Use your preferred text editor to open the MySQL server configuration file:
sudo nano /etc/mysql/mysql.conf.d/mysqld.cnf
Scroll down to the bind-address line and ensure that is either commented out or replaced with 0.0.0.0 (to allow all remote connections) or replaced with Ip-Addresses that you want remote connections from.
Once you make the necessary changes, save and exit the configuration file. Apply the changes made to the MySQL config file by restarting the MySQL service:
sudo systemctl restart mysql
Next, log into the MySQL server console on the server it was installed:
mysql -u root -p
Enter your mysql user password
Check the hosts that the user you want has access to already. In my case the user is root:
SELECT host FROM mysql.user WHERE user = "root";
This gave me this output:
+-----------+
| host |
+-----------+
| localhost |
+-----------+
Next, I ran the command below which is similar to the previous one that was throwing errors, but notice that I added a password to it this time:
USE database_name;
GRANT ALL PRIVILEGES ON *.* TO 'root'#'%' IDENTIFIED BY 'my-password';
Note: % grants a user remote access from all hosts on a network. You can specify the Ip-Address of the individual hosts that you want to grant the user access from using the command - GRANT ALL PRIVILEGES ON *.* TO 'root'#'Ip-Address' IDENTIFIED BY 'my-password';
Afterwhich I checked the hosts that the user now has access to. In my case the user is root:
SELECT host FROM mysql.user WHERE user = "root";
This gave me this output:
+-----------+
| host |
+-----------+
| % |
| localhost |
+-----------+
Finally, you can try connecting to the MySQL server from another server using the command:
mysql -u username -h mysql-server-ip-address -p
Where u represents user, h represents mysql-server-ip-address and p represents password. So in my case it was:
mysql -u root -h 34.69.261.158 -p
Enter your mysql user password
You should get this output depending on your MySQL server version:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.31 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
Resources: How to Allow Remote Connections to MySQL
That's all.
I hope this helps
grant all on newdb.* to newuser#localhost identified by 'password';
For someone who is doing a mistake like me.
I was using command
SET PASSWORD FOR root = 'elephant7'
to update the password for the root user and I was getting the same error. I tried every thing mention above in all the answer but I got no success then after searching a bit I found out the ans,
MySQL account names consist of a user name and a host name. This enables creation of accounts for users with the same name who can connect from different hosts.
on https://dba.stackexchange.com/
and then I used the command
SET PASSWORD FOR 'root'#'localhost'=PASSWORD('mynewpasword');
here 'root'#'localhost' did the trick and the command worked.
Hope this be beneficial for someone.
If you're using PHPMyAdmin you have to be logged in as root to be able to change root password. in user put root than leave password blank than change your password.
In my case I had just renamed the Mysql user which was going to change his password on a gui based db tool (DbVisualizer). The terminal in which I tried to 'SET PASSWORD' did not work(MySQL Error #1133).
However this answer worked for me, even after changing the password the 'SET PASSWORD' command did not work yet.
After closing the terminal and opening new one the command worked very well.
I think the answer is here now : https://bugs.mysql.com/bug.php?id=83822
So, you should write :
GRANT ALL PRIVILEGES ON mydb.* to myuser#'xxx.xxx.xxx.xxx' IDENTIFIED BY 'mypassword';
And i think that could be work :
SET PASSWORD FOR myuser#'xxx.xxx.xxx.xxx' IDENTIFIED BY 'old_password' = PASSWORD('new_password');
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.