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
Asked
10 years, 1 month ago
Viewed
34k times
I am constantly get the following error message:
1045 Cannot log in to the MySQL server
I have tried the following:
-
sudo service mysql stop(Went fine) -
sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &(Went fine) -
mysql -u root(Went fine) -
FLUSH PRIVILEGES;(Went fine) -
SET PASSWORD FOR root@'localhost' = PASSWORD('password');(I get the following error:)ERROR 1133 (42000): Can't find any matching row in the user table mysql> select User from mysql.user; +------------------+ | User | +------------------+ | linux | | root | | debian-sys-maint | +------------------+ 3 rows in set (0.00 sec)
Alvar
16.8k29 gold badges91 silver badges131 bronze badges
asked Jan 10, 2013 at 11:09
18
When you do
SET PASSWORD FOR root@'localhost' = PASSWORD('password');
you are updating the password for a user that has name root and location localhost. From your result of your user table I conclude that there is NO such line. There seems to be a line with root and 127.0.0.1, so therefore you probably need this line.
SET PASSWORD FOR root@'127.0.0.1' = PASSWORD('password');
Please try and understand what the difference between the two lines is, and why this should be done instead of the former: I hope this helps you see what was wrong and why you should do this, as it might be not spot-on: the comment-additions would be much easier to read if they are in the question, and formatted correctly 
answered Jan 22, 2013 at 15:42
NanneNanne
8,5455 gold badges39 silver badges50 bronze badges
5
- Forum
- The Ubuntu Forum Community
- Ubuntu Specialised Support
- Ubuntu Servers, Cloud and Juju
- Server Platforms
- [ubuntu] mysql: ERROR 1133 (42000): Can’t find any matching row in the user table
-
mysql: ERROR 1133 (42000): Can’t find any matching row in the user table
I installed the ubuntu 16.04 beta2, want to setup the roundcube mail for my mail serer:
mysql> CREATE DATABASE roundcubemail DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
that work ok now i run this command but get error:
mysql> GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY »;
ERROR 1133 (42000): Can’t find any matching row in the user tableAlso i run this command and get error:
mysql>SET PASSWORD FOR root@’127.0.0.1′ = PASSWORD(»);
ERROR 1133 (42000): Can’t find any matching row in the user tableWhile configuration by dpkg i set the empty password for mysql root.
-
Re: mysql: ERROR 1133 (42000): Can’t find any matching row in the user table
Thread moved to the «Server Platforms» forum.
-
Re: mysql: ERROR 1133 (42000): Can’t find any matching row in the user table
You missed some of the GRANT statement. Try
Code:
GRANT ALL PRIVILEGES ON roundcubemail.* TO roundcube@localhost IDENTIFIED BY 'password'; flush privileges;
where ‘password’ should be in this format ‘the_word’
Should say 1 row updated.
Windows assumes the user is an idiot.
Linux demands proof.
-
Re: mysql: ERROR 1133 (42000): Can’t find any matching row in the user table
Also I don’t see mentioned whether you created the roundcube user in mysql. I see you created the database, but to be able to grant privileges the user has to be created too. On top of what Habitual said above, to correct the syntax of the GRANT statement.
Darko.
————————————————————————
Ubuntu 18.04 LTS 64bit


