Host 'xxx.xx.xxx.xxx' is not allowed to connect to this MySQL server









up vote
528
down vote

favorite
180












This should be dead simple, but I cannot get it to work for the life of me.

I'm just trying to connect remotely to my MySQL server.



connecting as



mysql -u root -h localhost -p 


works fine, but trying



mysql -u root -h 'any ip address here' -p


fails with the error



ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server


In the mysql.user table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.



I'm at my wits' end, and have no idea how to proceed.
Any ideas are welcome.










share|improve this question



















  • 2




    This link explains about the error: webyog.com/faq/content/23/36/en/…
    – Ashwin A
    Aug 6 '12 at 11:33










  • Can't login as root in most circumstances due to security precaution..
    – Andrew Odendaal
    Oct 22 at 12:38














up vote
528
down vote

favorite
180












This should be dead simple, but I cannot get it to work for the life of me.

I'm just trying to connect remotely to my MySQL server.



connecting as



mysql -u root -h localhost -p 


works fine, but trying



mysql -u root -h 'any ip address here' -p


fails with the error



ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server


In the mysql.user table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.



I'm at my wits' end, and have no idea how to proceed.
Any ideas are welcome.










share|improve this question



















  • 2




    This link explains about the error: webyog.com/faq/content/23/36/en/…
    – Ashwin A
    Aug 6 '12 at 11:33










  • Can't login as root in most circumstances due to security precaution..
    – Andrew Odendaal
    Oct 22 at 12:38












up vote
528
down vote

favorite
180









up vote
528
down vote

favorite
180






180





This should be dead simple, but I cannot get it to work for the life of me.

I'm just trying to connect remotely to my MySQL server.



connecting as



mysql -u root -h localhost -p 


works fine, but trying



mysql -u root -h 'any ip address here' -p


fails with the error



ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server


In the mysql.user table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.



I'm at my wits' end, and have no idea how to proceed.
Any ideas are welcome.










share|improve this question















This should be dead simple, but I cannot get it to work for the life of me.

I'm just trying to connect remotely to my MySQL server.



connecting as



mysql -u root -h localhost -p 


works fine, but trying



mysql -u root -h 'any ip address here' -p


fails with the error



ERROR 1130 (00000): Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server


In the mysql.user table, there is exactly the same entry for user 'root' with host 'localhost' as another with host '%'.



I'm at my wits' end, and have no idea how to proceed.
Any ideas are welcome.







mysql mysql-error-1130






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 28 '11 at 16:16









Lightness Races in Orbit

278k51445763




278k51445763










asked Oct 13 '09 at 12:40









concept47

12k103667




12k103667







  • 2




    This link explains about the error: webyog.com/faq/content/23/36/en/…
    – Ashwin A
    Aug 6 '12 at 11:33










  • Can't login as root in most circumstances due to security precaution..
    – Andrew Odendaal
    Oct 22 at 12:38












  • 2




    This link explains about the error: webyog.com/faq/content/23/36/en/…
    – Ashwin A
    Aug 6 '12 at 11:33










  • Can't login as root in most circumstances due to security precaution..
    – Andrew Odendaal
    Oct 22 at 12:38







2




2




This link explains about the error: webyog.com/faq/content/23/36/en/…
– Ashwin A
Aug 6 '12 at 11:33




This link explains about the error: webyog.com/faq/content/23/36/en/…
– Ashwin A
Aug 6 '12 at 11:33












Can't login as root in most circumstances due to security precaution..
– Andrew Odendaal
Oct 22 at 12:38




Can't login as root in most circumstances due to security precaution..
– Andrew Odendaal
Oct 22 at 12:38












21 Answers
21






active

oldest

votes

















up vote
639
down vote



accepted










Possibly a security precaution. You could try adding a new administrator account:



mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
-> WITH GRANT OPTION;
mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
-> WITH GRANT OPTION;


Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.



Edit:



From the MySQL FAQ:




If you cannot figure out why you get
Access denied, remove from the user
table all entries that have Host
values containing wildcards (entries
that contain '%' or '_' characters). A
very common error is to insert a new
entry with Host='%' and
User='some_user', thinking that this
allows you to specify localhost to
connect from the same machine. The
reason that this does not work is that
the default privileges include an
entry with Host='localhost' and
User=''. Because that entry has a Host
value 'localhost' that is more
specific than '%', it is used in
preference to the new entry when
connecting from localhost! The correct
procedure is to insert a second entry
with Host='localhost' and
User='some_user', or to delete the
entry with Host='localhost' and
User=''. After deleting the entry,
remember to issue a FLUSH PRIVILEGES
statement to reload the grant tables.
See also Section 5.4.4, “Access
Control, Stage 1: Connection
Verification”.







share|improve this answer


















  • 13




    Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
    – Corey Ballou
    Oct 13 '09 at 12:50






  • 3




    Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
    – Yannick Motton
    Oct 13 '09 at 12:58






  • 2




    I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
    – Yannick Motton
    Oct 13 '09 at 13:11






  • 2




    That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
    – Pascal Thivent
    Oct 13 '09 at 13:26






  • 1




    I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
    – Gustavo Guevara
    Jul 26 '14 at 15:20


















up vote
208
down vote













One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:



CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

CREATE USER 'username'@'%' IDENTIFIED BY 'password';

GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

FLUSH PRIVILEGES;


Once done with all four queries, it should connect with username / password






share|improve this answer


















  • 2




    You have to create a new user?
    – User
    Jun 19 '14 at 2:45






  • 2




    @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
    – Aditya P Bhatt
    Jun 19 '14 at 6:45






  • 3




    Had to restart mysql after completing the above steps for this to work for me.
    – tollbooth
    Sep 26 '15 at 18:20






  • 1




    A new user for every new host, no....
    – mckenzm
    Aug 13 '16 at 20:09










  • Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
    – Sorin Postelnicu
    Jan 10 '17 at 16:58

















up vote
84
down vote













My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.



My setup:



  • Ubuntu 14.04 LTS

  • MySQL v5.5.37

Solution



  1. Open up the file under 'etc/mysql/my.cnf'


  2. Check for:



    • port (by default this is 'port = 3306')

    • bind-address (by default this is 'bind-address = 127.0.0.1'; if you want to open to all then just comment out this line. For my example, I'll say the actual server is on 10.1.1.7)



  3. Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)



    mysql -u root -p
    Enter password: <enter password>
    mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
    mysql>FLUSH PRIVILEGES;
    mysql>exit


  4. sudo service mysqld restart


  5. You should now be able to remote connect to your database. For example, I'm using MySQL Workbench and putting in 'Hostname:10.1.1.7', 'Port:3306', 'Username:root'





share|improve this answer


















  • 1




    You can skip the use dataentry line (since most people won't have that database created).
    – Jedidja
    May 4 '15 at 20:24






  • 3




    i was able to do this without restarting the mysql service at the end
    – Ryan Tuck
    Oct 22 '15 at 19:23






  • 2




    FLUSH PRIVILEGES should allow you to not need to restart.
    – Adam B
    Apr 9 '16 at 1:04

















up vote
65
down vote













You need to grant access to the user from any hostname.



This is how you add new privilege from phpmyadmin



Goto Privileges > Add a new User



enter image description here



Select Any Host for the desired username



enter image description here






share|improve this answer
















  • 3




    what would the cli command to do this be?
    – Jonathan
    Mar 8 '17 at 18:53

















up vote
52
down vote













Just perform the following steps:



1) Connect to mysql



mysql -uroot -p


2) Create user



CREATE USER 'user'@'%' IDENTIFIED BY 'password';


3) Grant permissions



 GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;


4) Flush priviledges



FLUSH PRIVILEGES;





share|improve this answer


















  • 2




    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
    – Gank
    Dec 1 '15 at 5:33






  • 5




    Should *.* be *.* ?
    – sgarg
    Apr 7 '16 at 16:48











  • I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
    – Erica Kane
    Oct 12 '17 at 21:33

















up vote
23
down vote













The message *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server is a reply from the MySQL server to the MySQL client. Notice how its returning the IP address and not the hostname.



If you're trying to connect with mysql -h<hostname> -u<somebody> -p and it returns this message with the IP address, then the MySQL server isn't able to do a reverse lookup on the client. This is critical because thats how it maps the MySQL client to the grants.



Make sure you can do an nslookup <mysqlclient> FROM the MySQL server. If that doesn't work, then there's no entry in the DNS server. Alternatively, you can put an entry in the MySQL server's HOSTS file (<ipaddress> <fullyqualifiedhostname> <hostname> <- The order here might matter).



An entry in my server's host file allowing a reverse lookup of the MySQL client solved this very problem.






share|improve this answer


















  • 1




    "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
    – PJ Brunet
    May 31 '13 at 22:51

















up vote
13
down vote













If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute
a FLUSH PRIVILEGES statement to tell the server to reload the grant tables.



PS: I wouldn't recommend to allow any host to connect for any user (especially not the root use). If you are using mysql for a client/server application, prefer a subnet address. If you are using mysql with a web server or application server, use specific IPs.






share|improve this answer


















  • 1




    +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
    – Yannick Motton
    Oct 13 '09 at 13:30

















up vote
3
down vote













simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges



 FLUSH PRIVILEGES;





share|improve this answer




















  • This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
    – Lanklaas
    Jul 4 '17 at 17:41

















up vote
2
down vote













Just use the interface provided by MySql's GUI Tool (SQLyog):



Click on User manager:
enter image description here



Now, if you want to grant access FOR ANY OTHER REMOTE PC, just make sure that, just like in the underneath picture, the Host field value is % (which is the wildcard)



enter image description here






share|improve this answer



























    up vote
    2
    down vote













    If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:



    flush privileges;


    This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.






    share|improve this answer



























      up vote
      1
      down vote













      Well what you can do is just open mysql.cfg file and you have to change Bind-address to this



      bind-address = 127.0.0.1



      and then Restart mysql and you will able to connect that server to this.



      Look this you can have idea form that.



      this is real sol






      share|improve this answer


















      • 3




        This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
        – axon
        Feb 6 '14 at 18:49










      • But this is address which will allow all the Host to get connected to the server na?
        – Krishna
        Feb 7 '14 at 5:10










      • But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
        – Krishna
        Feb 7 '14 at 5:11

















      up vote
      1
      down vote













      If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".






      share|improve this answer



























        up vote
        1
        down vote













        Most of the answers here show you creating users with two host values: one for localhost, and one for %.



        Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use



        CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
        GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;


        and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)






        share|improve this answer



























          up vote
          1
          down vote













          Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)



          simply go to the target server DB in your control panel, in my case:
          MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
          enter image description here



          I guess there is a similar option on other C.panels like plesk, etc..



          I'm hope it was helpful to you too.






          share|improve this answer



























            up vote
            0
            down vote













            On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:



            I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.



            So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.






            share|improve this answer



























              up vote
              0
              down vote













              I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel



              Suppose you are trying to connect database of server B from server A.
              Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.






              share|improve this answer





























                up vote
                0
                down vote













                Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64.
                Mysql refuses connections - period.



                Solution:



                $ ls -l /var/lib/mysql/mysql/user.*
                -rw-rw---- 1 mysql mysql 0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
                -rw-rw---- 1 mysql mysql 1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
                -rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm


                File user.MYD has 0 size (really ?!).
                I copied all 3 files from another working system.



                $ /usr/sbin/rcmysql stop
                $ cd /var/lib/mysql/mysql/
                $ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
                $ /usr/sbin/rcmysql start
                $ cd -
                $ mysql -u root -p


                I was able to log in. Then, it was just a matter of re-applying all schema privileges.
                Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.






                share|improve this answer



























                  up vote
                  0
                  down vote













                  This answer might help someone...



                  All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)



                  I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!






                  share|improve this answer



























                    up vote
                    0
                    down vote













                    Simple way:



                    Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 


                    then



                    FLUSH PRIVILEGES;


                    done!






                    share|improve this answer



























                      up vote
                      -1
                      down vote













                      if you are trying to execute mysql query withouth defining connectionstring, you will get this error.



                      Probably you forgat to define connection string before execution. have you check this out?
                      (sorry for bad english)






                      share|improve this answer



























                        up vote
                        -1
                        down vote













                        All of the answers here didn't work in my case so I guest this may help other users in the future. This can also be a problem in our code, not just in MySQL alone.



                        If you are using VB.NET



                        Instead of this code:



                         Dim server As String = My.Settings.DB_Server
                        Dim username As String = My.Settings.DB_Username
                        Dim password As String = My.Settings.DB_Password
                        Dim database As String = My.Settings.DB_Database

                        MysqlConn.ConnectionString = "server=" & server & ";" _
                        & "user id=" & username & ";" _
                        & "password=" & password & ";" _
                        & "database=" & database

                        MysqlConn = New MySqlConnection()


                        You need to move MysqlConn = New MySqlConnection() on the first line. So it would be like this



                         MysqlConn = New MySqlConnection()

                        Dim server As String = My.Settings.DB_Server
                        Dim username As String = My.Settings.DB_Username
                        Dim password As String = My.Settings.DB_Password
                        Dim database As String = My.Settings.DB_Database

                        MysqlConn.ConnectionString = "server=" & server & ";" _
                        & "user id=" & username & ";" _
                        & "password=" & password & ";" _
                        & "database=" & database





                        share|improve this answer





















                          protected by cimmanon Dec 2 '15 at 22:34



                          Thank you for your interest in this question.
                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                          Would you like to answer one of these unanswered questions instead?














                          21 Answers
                          21






                          active

                          oldest

                          votes








                          21 Answers
                          21






                          active

                          oldest

                          votes









                          active

                          oldest

                          votes






                          active

                          oldest

                          votes








                          up vote
                          639
                          down vote



                          accepted










                          Possibly a security precaution. You could try adding a new administrator account:



                          mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
                          -> WITH GRANT OPTION;
                          mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
                          -> WITH GRANT OPTION;


                          Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.



                          Edit:



                          From the MySQL FAQ:




                          If you cannot figure out why you get
                          Access denied, remove from the user
                          table all entries that have Host
                          values containing wildcards (entries
                          that contain '%' or '_' characters). A
                          very common error is to insert a new
                          entry with Host='%' and
                          User='some_user', thinking that this
                          allows you to specify localhost to
                          connect from the same machine. The
                          reason that this does not work is that
                          the default privileges include an
                          entry with Host='localhost' and
                          User=''. Because that entry has a Host
                          value 'localhost' that is more
                          specific than '%', it is used in
                          preference to the new entry when
                          connecting from localhost! The correct
                          procedure is to insert a second entry
                          with Host='localhost' and
                          User='some_user', or to delete the
                          entry with Host='localhost' and
                          User=''. After deleting the entry,
                          remember to issue a FLUSH PRIVILEGES
                          statement to reload the grant tables.
                          See also Section 5.4.4, “Access
                          Control, Stage 1: Connection
                          Verification”.







                          share|improve this answer


















                          • 13




                            Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                            – Corey Ballou
                            Oct 13 '09 at 12:50






                          • 3




                            Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                            – Yannick Motton
                            Oct 13 '09 at 12:58






                          • 2




                            I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                            – Yannick Motton
                            Oct 13 '09 at 13:11






                          • 2




                            That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                            – Pascal Thivent
                            Oct 13 '09 at 13:26






                          • 1




                            I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                            – Gustavo Guevara
                            Jul 26 '14 at 15:20















                          up vote
                          639
                          down vote



                          accepted










                          Possibly a security precaution. You could try adding a new administrator account:



                          mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
                          -> WITH GRANT OPTION;
                          mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
                          -> WITH GRANT OPTION;


                          Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.



                          Edit:



                          From the MySQL FAQ:




                          If you cannot figure out why you get
                          Access denied, remove from the user
                          table all entries that have Host
                          values containing wildcards (entries
                          that contain '%' or '_' characters). A
                          very common error is to insert a new
                          entry with Host='%' and
                          User='some_user', thinking that this
                          allows you to specify localhost to
                          connect from the same machine. The
                          reason that this does not work is that
                          the default privileges include an
                          entry with Host='localhost' and
                          User=''. Because that entry has a Host
                          value 'localhost' that is more
                          specific than '%', it is used in
                          preference to the new entry when
                          connecting from localhost! The correct
                          procedure is to insert a second entry
                          with Host='localhost' and
                          User='some_user', or to delete the
                          entry with Host='localhost' and
                          User=''. After deleting the entry,
                          remember to issue a FLUSH PRIVILEGES
                          statement to reload the grant tables.
                          See also Section 5.4.4, “Access
                          Control, Stage 1: Connection
                          Verification”.







                          share|improve this answer


















                          • 13




                            Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                            – Corey Ballou
                            Oct 13 '09 at 12:50






                          • 3




                            Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                            – Yannick Motton
                            Oct 13 '09 at 12:58






                          • 2




                            I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                            – Yannick Motton
                            Oct 13 '09 at 13:11






                          • 2




                            That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                            – Pascal Thivent
                            Oct 13 '09 at 13:26






                          • 1




                            I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                            – Gustavo Guevara
                            Jul 26 '14 at 15:20













                          up vote
                          639
                          down vote



                          accepted







                          up vote
                          639
                          down vote



                          accepted






                          Possibly a security precaution. You could try adding a new administrator account:



                          mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
                          -> WITH GRANT OPTION;
                          mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
                          -> WITH GRANT OPTION;


                          Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.



                          Edit:



                          From the MySQL FAQ:




                          If you cannot figure out why you get
                          Access denied, remove from the user
                          table all entries that have Host
                          values containing wildcards (entries
                          that contain '%' or '_' characters). A
                          very common error is to insert a new
                          entry with Host='%' and
                          User='some_user', thinking that this
                          allows you to specify localhost to
                          connect from the same machine. The
                          reason that this does not work is that
                          the default privileges include an
                          entry with Host='localhost' and
                          User=''. Because that entry has a Host
                          value 'localhost' that is more
                          specific than '%', it is used in
                          preference to the new entry when
                          connecting from localhost! The correct
                          procedure is to insert a second entry
                          with Host='localhost' and
                          User='some_user', or to delete the
                          entry with Host='localhost' and
                          User=''. After deleting the entry,
                          remember to issue a FLUSH PRIVILEGES
                          statement to reload the grant tables.
                          See also Section 5.4.4, “Access
                          Control, Stage 1: Connection
                          Verification”.







                          share|improve this answer














                          Possibly a security precaution. You could try adding a new administrator account:



                          mysql> CREATE USER 'monty'@'localhost' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'localhost'
                          -> WITH GRANT OPTION;
                          mysql> CREATE USER 'monty'@'%' IDENTIFIED BY 'some_pass';
                          mysql> GRANT ALL PRIVILEGES ON *.* TO 'monty'@'%'
                          -> WITH GRANT OPTION;


                          Although as Pascal and others have noted it's not a great idea to have a user with this kind of access open to any IP. If you need an administrative user, use root, and leave it on localhost. For any other action specify exactly the privileges you need and limit the accessibility of the user as Pascal has suggest below.



                          Edit:



                          From the MySQL FAQ:




                          If you cannot figure out why you get
                          Access denied, remove from the user
                          table all entries that have Host
                          values containing wildcards (entries
                          that contain '%' or '_' characters). A
                          very common error is to insert a new
                          entry with Host='%' and
                          User='some_user', thinking that this
                          allows you to specify localhost to
                          connect from the same machine. The
                          reason that this does not work is that
                          the default privileges include an
                          entry with Host='localhost' and
                          User=''. Because that entry has a Host
                          value 'localhost' that is more
                          specific than '%', it is used in
                          preference to the new entry when
                          connecting from localhost! The correct
                          procedure is to insert a second entry
                          with Host='localhost' and
                          User='some_user', or to delete the
                          entry with Host='localhost' and
                          User=''. After deleting the entry,
                          remember to issue a FLUSH PRIVILEGES
                          statement to reload the grant tables.
                          See also Section 5.4.4, “Access
                          Control, Stage 1: Connection
                          Verification”.








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Oct 13 '09 at 13:25

























                          answered Oct 13 '09 at 12:47









                          Yannick Motton

                          23.9k43352




                          23.9k43352







                          • 13




                            Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                            – Corey Ballou
                            Oct 13 '09 at 12:50






                          • 3




                            Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                            – Yannick Motton
                            Oct 13 '09 at 12:58






                          • 2




                            I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                            – Yannick Motton
                            Oct 13 '09 at 13:11






                          • 2




                            That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                            – Pascal Thivent
                            Oct 13 '09 at 13:26






                          • 1




                            I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                            – Gustavo Guevara
                            Jul 26 '14 at 15:20













                          • 13




                            Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                            – Corey Ballou
                            Oct 13 '09 at 12:50






                          • 3




                            Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                            – Yannick Motton
                            Oct 13 '09 at 12:58






                          • 2




                            I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                            – Yannick Motton
                            Oct 13 '09 at 13:11






                          • 2




                            That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                            – Pascal Thivent
                            Oct 13 '09 at 13:26






                          • 1




                            I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                            – Gustavo Guevara
                            Jul 26 '14 at 15:20








                          13




                          13




                          Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                          – Corey Ballou
                          Oct 13 '09 at 12:50




                          Good catch Yannick, however I would not recommend him granting all privileges to a non-root user. Perhaps a reduced set?
                          – Corey Ballou
                          Oct 13 '09 at 12:50




                          3




                          3




                          Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                          – Yannick Motton
                          Oct 13 '09 at 12:58




                          Well, this indeed wouldn't be a good idea, but allowing 'root' to connect from all hosts is exactly the same, since it is at the same privilege level.
                          – Yannick Motton
                          Oct 13 '09 at 12:58




                          2




                          2




                          I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                          – Yannick Motton
                          Oct 13 '09 at 13:11




                          I think you miss my point Pascal. The point is that the 'root' user has those rights already, and he wants to let any ip authenticate as that user. So if this is really what he wants, the default example of creating a new administrator user (which has exactly the same rights) is an alternative to what he's trying.
                          – Yannick Motton
                          Oct 13 '09 at 13:11




                          2




                          2




                          That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                          – Pascal Thivent
                          Oct 13 '09 at 13:26




                          That's right Yannick, I read to fast and will remove my comment. However, AFAIK, permissions are working fine in MySQL so: 1. maybe the OP modified the grant tables manually and then need to flush privileges. 2. maybe he didn't use the proper grant syntax for root. Adding another administrative user might be a workaround but it won't solve the real issue IMHO.
                          – Pascal Thivent
                          Oct 13 '09 at 13:26




                          1




                          1




                          I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                          – Gustavo Guevara
                          Jul 26 '14 at 15:20





                          I felt that providing access from all hosts to root was not a proper solution. Instead I created a new user and granted a reduced set of privileges, the set I used is described as 'DBManager' on MySQL Workbench. I also only allowed access from a certain group of hosts in my local network, particularly 192.168.0.%
                          – Gustavo Guevara
                          Jul 26 '14 at 15:20













                          up vote
                          208
                          down vote













                          One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:



                          CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

                          CREATE USER 'username'@'%' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

                          FLUSH PRIVILEGES;


                          Once done with all four queries, it should connect with username / password






                          share|improve this answer


















                          • 2




                            You have to create a new user?
                            – User
                            Jun 19 '14 at 2:45






                          • 2




                            @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                            – Aditya P Bhatt
                            Jun 19 '14 at 6:45






                          • 3




                            Had to restart mysql after completing the above steps for this to work for me.
                            – tollbooth
                            Sep 26 '15 at 18:20






                          • 1




                            A new user for every new host, no....
                            – mckenzm
                            Aug 13 '16 at 20:09










                          • Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                            – Sorin Postelnicu
                            Jan 10 '17 at 16:58














                          up vote
                          208
                          down vote













                          One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:



                          CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

                          CREATE USER 'username'@'%' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

                          FLUSH PRIVILEGES;


                          Once done with all four queries, it should connect with username / password






                          share|improve this answer


















                          • 2




                            You have to create a new user?
                            – User
                            Jun 19 '14 at 2:45






                          • 2




                            @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                            – Aditya P Bhatt
                            Jun 19 '14 at 6:45






                          • 3




                            Had to restart mysql after completing the above steps for this to work for me.
                            – tollbooth
                            Sep 26 '15 at 18:20






                          • 1




                            A new user for every new host, no....
                            – mckenzm
                            Aug 13 '16 at 20:09










                          • Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                            – Sorin Postelnicu
                            Jan 10 '17 at 16:58












                          up vote
                          208
                          down vote










                          up vote
                          208
                          down vote









                          One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:



                          CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

                          CREATE USER 'username'@'%' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

                          FLUSH PRIVILEGES;


                          Once done with all four queries, it should connect with username / password






                          share|improve this answer














                          One has to create a new MySQL User and assign privileges as below in Query prompt via phpMyAdmin or command prompt:



                          CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'localhost' WITH GRANT OPTION;

                          CREATE USER 'username'@'%' IDENTIFIED BY 'password';

                          GRANT ALL PRIVILEGES ON *.* TO 'username'@'%' WITH GRANT OPTION;

                          FLUSH PRIVILEGES;


                          Once done with all four queries, it should connect with username / password







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Aug 10 '15 at 18:26









                          Andrey Mikhaylov - lolmaus

                          17.5k455101




                          17.5k455101










                          answered Sep 16 '13 at 5:56









                          Aditya P Bhatt

                          14.4k157395




                          14.4k157395







                          • 2




                            You have to create a new user?
                            – User
                            Jun 19 '14 at 2:45






                          • 2




                            @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                            – Aditya P Bhatt
                            Jun 19 '14 at 6:45






                          • 3




                            Had to restart mysql after completing the above steps for this to work for me.
                            – tollbooth
                            Sep 26 '15 at 18:20






                          • 1




                            A new user for every new host, no....
                            – mckenzm
                            Aug 13 '16 at 20:09










                          • Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                            – Sorin Postelnicu
                            Jan 10 '17 at 16:58












                          • 2




                            You have to create a new user?
                            – User
                            Jun 19 '14 at 2:45






                          • 2




                            @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                            – Aditya P Bhatt
                            Jun 19 '14 at 6:45






                          • 3




                            Had to restart mysql after completing the above steps for this to work for me.
                            – tollbooth
                            Sep 26 '15 at 18:20






                          • 1




                            A new user for every new host, no....
                            – mckenzm
                            Aug 13 '16 at 20:09










                          • Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                            – Sorin Postelnicu
                            Jan 10 '17 at 16:58







                          2




                          2




                          You have to create a new user?
                          – User
                          Jun 19 '14 at 2:45




                          You have to create a new user?
                          – User
                          Jun 19 '14 at 2:45




                          2




                          2




                          @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                          – Aditya P Bhatt
                          Jun 19 '14 at 6:45




                          @macdonjo: yes create new user with new password and grant privileges as mentioned above, it should work
                          – Aditya P Bhatt
                          Jun 19 '14 at 6:45




                          3




                          3




                          Had to restart mysql after completing the above steps for this to work for me.
                          – tollbooth
                          Sep 26 '15 at 18:20




                          Had to restart mysql after completing the above steps for this to work for me.
                          – tollbooth
                          Sep 26 '15 at 18:20




                          1




                          1




                          A new user for every new host, no....
                          – mckenzm
                          Aug 13 '16 at 20:09




                          A new user for every new host, no....
                          – mckenzm
                          Aug 13 '16 at 20:09












                          Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                          – Sorin Postelnicu
                          Jan 10 '17 at 16:58




                          Do you have to create username@localhost? Is it not enough if you just create username@% ? I mean, if you just create username@%, will you not be able to connect with that user from localhost?
                          – Sorin Postelnicu
                          Jan 10 '17 at 16:58










                          up vote
                          84
                          down vote













                          My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.



                          My setup:



                          • Ubuntu 14.04 LTS

                          • MySQL v5.5.37

                          Solution



                          1. Open up the file under 'etc/mysql/my.cnf'


                          2. Check for:



                            • port (by default this is 'port = 3306')

                            • bind-address (by default this is 'bind-address = 127.0.0.1'; if you want to open to all then just comment out this line. For my example, I'll say the actual server is on 10.1.1.7)



                          3. Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)



                            mysql -u root -p
                            Enter password: <enter password>
                            mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
                            mysql>FLUSH PRIVILEGES;
                            mysql>exit


                          4. sudo service mysqld restart


                          5. You should now be able to remote connect to your database. For example, I'm using MySQL Workbench and putting in 'Hostname:10.1.1.7', 'Port:3306', 'Username:root'





                          share|improve this answer


















                          • 1




                            You can skip the use dataentry line (since most people won't have that database created).
                            – Jedidja
                            May 4 '15 at 20:24






                          • 3




                            i was able to do this without restarting the mysql service at the end
                            – Ryan Tuck
                            Oct 22 '15 at 19:23






                          • 2




                            FLUSH PRIVILEGES should allow you to not need to restart.
                            – Adam B
                            Apr 9 '16 at 1:04














                          up vote
                          84
                          down vote













                          My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.



                          My setup:



                          • Ubuntu 14.04 LTS

                          • MySQL v5.5.37

                          Solution



                          1. Open up the file under 'etc/mysql/my.cnf'


                          2. Check for:



                            • port (by default this is 'port = 3306')

                            • bind-address (by default this is 'bind-address = 127.0.0.1'; if you want to open to all then just comment out this line. For my example, I'll say the actual server is on 10.1.1.7)



                          3. Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)



                            mysql -u root -p
                            Enter password: <enter password>
                            mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
                            mysql>FLUSH PRIVILEGES;
                            mysql>exit


                          4. sudo service mysqld restart


                          5. You should now be able to remote connect to your database. For example, I'm using MySQL Workbench and putting in 'Hostname:10.1.1.7', 'Port:3306', 'Username:root'





                          share|improve this answer


















                          • 1




                            You can skip the use dataentry line (since most people won't have that database created).
                            – Jedidja
                            May 4 '15 at 20:24






                          • 3




                            i was able to do this without restarting the mysql service at the end
                            – Ryan Tuck
                            Oct 22 '15 at 19:23






                          • 2




                            FLUSH PRIVILEGES should allow you to not need to restart.
                            – Adam B
                            Apr 9 '16 at 1:04












                          up vote
                          84
                          down vote










                          up vote
                          84
                          down vote









                          My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.



                          My setup:



                          • Ubuntu 14.04 LTS

                          • MySQL v5.5.37

                          Solution



                          1. Open up the file under 'etc/mysql/my.cnf'


                          2. Check for:



                            • port (by default this is 'port = 3306')

                            • bind-address (by default this is 'bind-address = 127.0.0.1'; if you want to open to all then just comment out this line. For my example, I'll say the actual server is on 10.1.1.7)



                          3. Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)



                            mysql -u root -p
                            Enter password: <enter password>
                            mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
                            mysql>FLUSH PRIVILEGES;
                            mysql>exit


                          4. sudo service mysqld restart


                          5. You should now be able to remote connect to your database. For example, I'm using MySQL Workbench and putting in 'Hostname:10.1.1.7', 'Port:3306', 'Username:root'





                          share|improve this answer














                          My error message was similar and said 'Host XXX is not allowed to connect to this MySQL server' even though I was using root. Here's how to make sure that root has the correct permissions.



                          My setup:



                          • Ubuntu 14.04 LTS

                          • MySQL v5.5.37

                          Solution



                          1. Open up the file under 'etc/mysql/my.cnf'


                          2. Check for:



                            • port (by default this is 'port = 3306')

                            • bind-address (by default this is 'bind-address = 127.0.0.1'; if you want to open to all then just comment out this line. For my example, I'll say the actual server is on 10.1.1.7)



                          3. Now access the MySQL Database on your actual server (say your remote address is 123.123.123.123 at port 3306 as user 'root' and I want to change permissions on database 'dataentry'. Remember to change the IP Address, Port, and database name to your settings)



                            mysql -u root -p
                            Enter password: <enter password>
                            mysql>GRANT ALL ON *.* to root@'123.123.123.123' IDENTIFIED BY 'put-your-password';
                            mysql>FLUSH PRIVILEGES;
                            mysql>exit


                          4. sudo service mysqld restart


                          5. You should now be able to remote connect to your database. For example, I'm using MySQL Workbench and putting in 'Hostname:10.1.1.7', 'Port:3306', 'Username:root'






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jun 27 at 13:15









                          marverix

                          2,34152742




                          2,34152742










                          answered Jun 11 '14 at 19:31









                          Will

                          7,23754764




                          7,23754764







                          • 1




                            You can skip the use dataentry line (since most people won't have that database created).
                            – Jedidja
                            May 4 '15 at 20:24






                          • 3




                            i was able to do this without restarting the mysql service at the end
                            – Ryan Tuck
                            Oct 22 '15 at 19:23






                          • 2




                            FLUSH PRIVILEGES should allow you to not need to restart.
                            – Adam B
                            Apr 9 '16 at 1:04












                          • 1




                            You can skip the use dataentry line (since most people won't have that database created).
                            – Jedidja
                            May 4 '15 at 20:24






                          • 3




                            i was able to do this without restarting the mysql service at the end
                            – Ryan Tuck
                            Oct 22 '15 at 19:23






                          • 2




                            FLUSH PRIVILEGES should allow you to not need to restart.
                            – Adam B
                            Apr 9 '16 at 1:04







                          1




                          1




                          You can skip the use dataentry line (since most people won't have that database created).
                          – Jedidja
                          May 4 '15 at 20:24




                          You can skip the use dataentry line (since most people won't have that database created).
                          – Jedidja
                          May 4 '15 at 20:24




                          3




                          3




                          i was able to do this without restarting the mysql service at the end
                          – Ryan Tuck
                          Oct 22 '15 at 19:23




                          i was able to do this without restarting the mysql service at the end
                          – Ryan Tuck
                          Oct 22 '15 at 19:23




                          2




                          2




                          FLUSH PRIVILEGES should allow you to not need to restart.
                          – Adam B
                          Apr 9 '16 at 1:04




                          FLUSH PRIVILEGES should allow you to not need to restart.
                          – Adam B
                          Apr 9 '16 at 1:04










                          up vote
                          65
                          down vote













                          You need to grant access to the user from any hostname.



                          This is how you add new privilege from phpmyadmin



                          Goto Privileges > Add a new User



                          enter image description here



                          Select Any Host for the desired username



                          enter image description here






                          share|improve this answer
















                          • 3




                            what would the cli command to do this be?
                            – Jonathan
                            Mar 8 '17 at 18:53














                          up vote
                          65
                          down vote













                          You need to grant access to the user from any hostname.



                          This is how you add new privilege from phpmyadmin



                          Goto Privileges > Add a new User



                          enter image description here



                          Select Any Host for the desired username



                          enter image description here






                          share|improve this answer
















                          • 3




                            what would the cli command to do this be?
                            – Jonathan
                            Mar 8 '17 at 18:53












                          up vote
                          65
                          down vote










                          up vote
                          65
                          down vote









                          You need to grant access to the user from any hostname.



                          This is how you add new privilege from phpmyadmin



                          Goto Privileges > Add a new User



                          enter image description here



                          Select Any Host for the desired username



                          enter image description here






                          share|improve this answer












                          You need to grant access to the user from any hostname.



                          This is how you add new privilege from phpmyadmin



                          Goto Privileges > Add a new User



                          enter image description here



                          Select Any Host for the desired username



                          enter image description here







                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Jun 21 '13 at 11:42









                          HimalayanCoder

                          5,91633644




                          5,91633644







                          • 3




                            what would the cli command to do this be?
                            – Jonathan
                            Mar 8 '17 at 18:53












                          • 3




                            what would the cli command to do this be?
                            – Jonathan
                            Mar 8 '17 at 18:53







                          3




                          3




                          what would the cli command to do this be?
                          – Jonathan
                          Mar 8 '17 at 18:53




                          what would the cli command to do this be?
                          – Jonathan
                          Mar 8 '17 at 18:53










                          up vote
                          52
                          down vote













                          Just perform the following steps:



                          1) Connect to mysql



                          mysql -uroot -p


                          2) Create user



                          CREATE USER 'user'@'%' IDENTIFIED BY 'password';


                          3) Grant permissions



                           GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;


                          4) Flush priviledges



                          FLUSH PRIVILEGES;





                          share|improve this answer


















                          • 2




                            ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                            – Gank
                            Dec 1 '15 at 5:33






                          • 5




                            Should *.* be *.* ?
                            – sgarg
                            Apr 7 '16 at 16:48











                          • I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                            – Erica Kane
                            Oct 12 '17 at 21:33














                          up vote
                          52
                          down vote













                          Just perform the following steps:



                          1) Connect to mysql



                          mysql -uroot -p


                          2) Create user



                          CREATE USER 'user'@'%' IDENTIFIED BY 'password';


                          3) Grant permissions



                           GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;


                          4) Flush priviledges



                          FLUSH PRIVILEGES;





                          share|improve this answer


















                          • 2




                            ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                            – Gank
                            Dec 1 '15 at 5:33






                          • 5




                            Should *.* be *.* ?
                            – sgarg
                            Apr 7 '16 at 16:48











                          • I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                            – Erica Kane
                            Oct 12 '17 at 21:33












                          up vote
                          52
                          down vote










                          up vote
                          52
                          down vote









                          Just perform the following steps:



                          1) Connect to mysql



                          mysql -uroot -p


                          2) Create user



                          CREATE USER 'user'@'%' IDENTIFIED BY 'password';


                          3) Grant permissions



                           GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;


                          4) Flush priviledges



                          FLUSH PRIVILEGES;





                          share|improve this answer














                          Just perform the following steps:



                          1) Connect to mysql



                          mysql -uroot -p


                          2) Create user



                          CREATE USER 'user'@'%' IDENTIFIED BY 'password';


                          3) Grant permissions



                           GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;


                          4) Flush priviledges



                          FLUSH PRIVILEGES;






                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited May 22 '14 at 12:31









                          avisheks

                          1,000924




                          1,000924










                          answered Mar 24 '14 at 9:27









                          minhas23

                          6,08014233




                          6,08014233







                          • 2




                            ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                            – Gank
                            Dec 1 '15 at 5:33






                          • 5




                            Should *.* be *.* ?
                            – sgarg
                            Apr 7 '16 at 16:48











                          • I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                            – Erica Kane
                            Oct 12 '17 at 21:33












                          • 2




                            ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                            – Gank
                            Dec 1 '15 at 5:33






                          • 5




                            Should *.* be *.* ?
                            – sgarg
                            Apr 7 '16 at 16:48











                          • I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                            – Erica Kane
                            Oct 12 '17 at 21:33







                          2




                          2




                          ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                          – Gank
                          Dec 1 '15 at 5:33




                          ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using passwoYES)Y
                          – Gank
                          Dec 1 '15 at 5:33




                          5




                          5




                          Should *.* be *.* ?
                          – sgarg
                          Apr 7 '16 at 16:48





                          Should *.* be *.* ?
                          – sgarg
                          Apr 7 '16 at 16:48













                          I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                          – Erica Kane
                          Oct 12 '17 at 21:33




                          I'm voting this up because this is the correct answer for every user other than root. Most users do not need a duplicate entry (though root does).
                          – Erica Kane
                          Oct 12 '17 at 21:33










                          up vote
                          23
                          down vote













                          The message *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server is a reply from the MySQL server to the MySQL client. Notice how its returning the IP address and not the hostname.



                          If you're trying to connect with mysql -h<hostname> -u<somebody> -p and it returns this message with the IP address, then the MySQL server isn't able to do a reverse lookup on the client. This is critical because thats how it maps the MySQL client to the grants.



                          Make sure you can do an nslookup <mysqlclient> FROM the MySQL server. If that doesn't work, then there's no entry in the DNS server. Alternatively, you can put an entry in the MySQL server's HOSTS file (<ipaddress> <fullyqualifiedhostname> <hostname> <- The order here might matter).



                          An entry in my server's host file allowing a reverse lookup of the MySQL client solved this very problem.






                          share|improve this answer


















                          • 1




                            "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                            – PJ Brunet
                            May 31 '13 at 22:51














                          up vote
                          23
                          down vote













                          The message *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server is a reply from the MySQL server to the MySQL client. Notice how its returning the IP address and not the hostname.



                          If you're trying to connect with mysql -h<hostname> -u<somebody> -p and it returns this message with the IP address, then the MySQL server isn't able to do a reverse lookup on the client. This is critical because thats how it maps the MySQL client to the grants.



                          Make sure you can do an nslookup <mysqlclient> FROM the MySQL server. If that doesn't work, then there's no entry in the DNS server. Alternatively, you can put an entry in the MySQL server's HOSTS file (<ipaddress> <fullyqualifiedhostname> <hostname> <- The order here might matter).



                          An entry in my server's host file allowing a reverse lookup of the MySQL client solved this very problem.






                          share|improve this answer


















                          • 1




                            "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                            – PJ Brunet
                            May 31 '13 at 22:51












                          up vote
                          23
                          down vote










                          up vote
                          23
                          down vote









                          The message *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server is a reply from the MySQL server to the MySQL client. Notice how its returning the IP address and not the hostname.



                          If you're trying to connect with mysql -h<hostname> -u<somebody> -p and it returns this message with the IP address, then the MySQL server isn't able to do a reverse lookup on the client. This is critical because thats how it maps the MySQL client to the grants.



                          Make sure you can do an nslookup <mysqlclient> FROM the MySQL server. If that doesn't work, then there's no entry in the DNS server. Alternatively, you can put an entry in the MySQL server's HOSTS file (<ipaddress> <fullyqualifiedhostname> <hostname> <- The order here might matter).



                          An entry in my server's host file allowing a reverse lookup of the MySQL client solved this very problem.






                          share|improve this answer














                          The message *Host ''xxx.xx.xxx.xxx'' is not allowed to connect to this MySQL server is a reply from the MySQL server to the MySQL client. Notice how its returning the IP address and not the hostname.



                          If you're trying to connect with mysql -h<hostname> -u<somebody> -p and it returns this message with the IP address, then the MySQL server isn't able to do a reverse lookup on the client. This is critical because thats how it maps the MySQL client to the grants.



                          Make sure you can do an nslookup <mysqlclient> FROM the MySQL server. If that doesn't work, then there's no entry in the DNS server. Alternatively, you can put an entry in the MySQL server's HOSTS file (<ipaddress> <fullyqualifiedhostname> <hostname> <- The order here might matter).



                          An entry in my server's host file allowing a reverse lookup of the MySQL client solved this very problem.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Mar 13 '12 at 13:42

























                          answered Mar 13 '12 at 13:37









                          Dennis McLaughlin

                          23123




                          23123







                          • 1




                            "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                            – PJ Brunet
                            May 31 '13 at 22:51












                          • 1




                            "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                            – PJ Brunet
                            May 31 '13 at 22:51







                          1




                          1




                          "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                          – PJ Brunet
                          May 31 '13 at 22:51




                          "is a reply from the MySQL server to the MySQL client." Thank you, I was wondering where the error was coming from, my machine or the server. I have error "ERROR 1130 (HY000):" etc.
                          – PJ Brunet
                          May 31 '13 at 22:51










                          up vote
                          13
                          down vote













                          If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute
                          a FLUSH PRIVILEGES statement to tell the server to reload the grant tables.



                          PS: I wouldn't recommend to allow any host to connect for any user (especially not the root use). If you are using mysql for a client/server application, prefer a subnet address. If you are using mysql with a web server or application server, use specific IPs.






                          share|improve this answer


















                          • 1




                            +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                            – Yannick Motton
                            Oct 13 '09 at 13:30














                          up vote
                          13
                          down vote













                          If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute
                          a FLUSH PRIVILEGES statement to tell the server to reload the grant tables.



                          PS: I wouldn't recommend to allow any host to connect for any user (especially not the root use). If you are using mysql for a client/server application, prefer a subnet address. If you are using mysql with a web server or application server, use specific IPs.






                          share|improve this answer


















                          • 1




                            +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                            – Yannick Motton
                            Oct 13 '09 at 13:30












                          up vote
                          13
                          down vote










                          up vote
                          13
                          down vote









                          If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute
                          a FLUSH PRIVILEGES statement to tell the server to reload the grant tables.



                          PS: I wouldn't recommend to allow any host to connect for any user (especially not the root use). If you are using mysql for a client/server application, prefer a subnet address. If you are using mysql with a web server or application server, use specific IPs.






                          share|improve this answer














                          If you modify the grant tables manually (using INSERT, UPDATE, etc.), you should execute
                          a FLUSH PRIVILEGES statement to tell the server to reload the grant tables.



                          PS: I wouldn't recommend to allow any host to connect for any user (especially not the root use). If you are using mysql for a client/server application, prefer a subnet address. If you are using mysql with a web server or application server, use specific IPs.







                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Oct 13 '09 at 13:05

























                          answered Oct 13 '09 at 12:56









                          Pascal Thivent

                          476k1109401057




                          476k1109401057







                          • 1




                            +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                            – Yannick Motton
                            Oct 13 '09 at 13:30












                          • 1




                            +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                            – Yannick Motton
                            Oct 13 '09 at 13:30







                          1




                          1




                          +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                          – Yannick Motton
                          Oct 13 '09 at 13:30




                          +1 I do agree with your recommendation, and the flush privileges might work if he made changes to the user table manually. (cleaned up old comments)
                          – Yannick Motton
                          Oct 13 '09 at 13:30










                          up vote
                          3
                          down vote













                          simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges



                           FLUSH PRIVILEGES;





                          share|improve this answer




















                          • This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                            – Lanklaas
                            Jul 4 '17 at 17:41














                          up vote
                          3
                          down vote













                          simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges



                           FLUSH PRIVILEGES;





                          share|improve this answer




















                          • This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                            – Lanklaas
                            Jul 4 '17 at 17:41












                          up vote
                          3
                          down vote










                          up vote
                          3
                          down vote









                          simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges



                           FLUSH PRIVILEGES;





                          share|improve this answer












                          simple way is to login to phpmyadmin with root account , there goto mysql database and select user table , there edit root account and in host field add % wild card . and then through ssh flush privileges



                           FLUSH PRIVILEGES;






                          share|improve this answer












                          share|improve this answer



                          share|improve this answer










                          answered Feb 21 '16 at 10:52









                          user889030

                          88911223




                          88911223











                          • This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                            – Lanklaas
                            Jul 4 '17 at 17:41
















                          • This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                            – Lanklaas
                            Jul 4 '17 at 17:41















                          This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                          – Lanklaas
                          Jul 4 '17 at 17:41




                          This helped me combined with this: GRANT ALL PRIVILEGES ON . TO 'root'@'%' WITH GRANT OPTION;
                          – Lanklaas
                          Jul 4 '17 at 17:41










                          up vote
                          2
                          down vote













                          Just use the interface provided by MySql's GUI Tool (SQLyog):



                          Click on User manager:
                          enter image description here



                          Now, if you want to grant access FOR ANY OTHER REMOTE PC, just make sure that, just like in the underneath picture, the Host field value is % (which is the wildcard)



                          enter image description here






                          share|improve this answer
























                            up vote
                            2
                            down vote













                            Just use the interface provided by MySql's GUI Tool (SQLyog):



                            Click on User manager:
                            enter image description here



                            Now, if you want to grant access FOR ANY OTHER REMOTE PC, just make sure that, just like in the underneath picture, the Host field value is % (which is the wildcard)



                            enter image description here






                            share|improve this answer






















                              up vote
                              2
                              down vote










                              up vote
                              2
                              down vote









                              Just use the interface provided by MySql's GUI Tool (SQLyog):



                              Click on User manager:
                              enter image description here



                              Now, if you want to grant access FOR ANY OTHER REMOTE PC, just make sure that, just like in the underneath picture, the Host field value is % (which is the wildcard)



                              enter image description here






                              share|improve this answer












                              Just use the interface provided by MySql's GUI Tool (SQLyog):



                              Click on User manager:
                              enter image description here



                              Now, if you want to grant access FOR ANY OTHER REMOTE PC, just make sure that, just like in the underneath picture, the Host field value is % (which is the wildcard)



                              enter image description here







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Sep 27 '17 at 13:09









                              BabaNew

                              321111




                              321111




















                                  up vote
                                  2
                                  down vote













                                  If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:



                                  flush privileges;


                                  This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.






                                  share|improve this answer
























                                    up vote
                                    2
                                    down vote













                                    If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:



                                    flush privileges;


                                    This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.






                                    share|improve this answer






















                                      up vote
                                      2
                                      down vote










                                      up vote
                                      2
                                      down vote









                                      If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:



                                      flush privileges;


                                      This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.






                                      share|improve this answer












                                      If this is a recent mysql install, then before changing anything else, try simply to execute this command and then try again:



                                      flush privileges;


                                      This alone fixes the issue for me on Ubuntu 16.04, mysql 5.7.20. YMMV.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 22 '17 at 5:54









                                      Alex R

                                      4,03294796




                                      4,03294796




















                                          up vote
                                          1
                                          down vote













                                          Well what you can do is just open mysql.cfg file and you have to change Bind-address to this



                                          bind-address = 127.0.0.1



                                          and then Restart mysql and you will able to connect that server to this.



                                          Look this you can have idea form that.



                                          this is real sol






                                          share|improve this answer


















                                          • 3




                                            This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                            – axon
                                            Feb 6 '14 at 18:49










                                          • But this is address which will allow all the Host to get connected to the server na?
                                            – Krishna
                                            Feb 7 '14 at 5:10










                                          • But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                            – Krishna
                                            Feb 7 '14 at 5:11














                                          up vote
                                          1
                                          down vote













                                          Well what you can do is just open mysql.cfg file and you have to change Bind-address to this



                                          bind-address = 127.0.0.1



                                          and then Restart mysql and you will able to connect that server to this.



                                          Look this you can have idea form that.



                                          this is real sol






                                          share|improve this answer


















                                          • 3




                                            This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                            – axon
                                            Feb 6 '14 at 18:49










                                          • But this is address which will allow all the Host to get connected to the server na?
                                            – Krishna
                                            Feb 7 '14 at 5:10










                                          • But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                            – Krishna
                                            Feb 7 '14 at 5:11












                                          up vote
                                          1
                                          down vote










                                          up vote
                                          1
                                          down vote









                                          Well what you can do is just open mysql.cfg file and you have to change Bind-address to this



                                          bind-address = 127.0.0.1



                                          and then Restart mysql and you will able to connect that server to this.



                                          Look this you can have idea form that.



                                          this is real sol






                                          share|improve this answer














                                          Well what you can do is just open mysql.cfg file and you have to change Bind-address to this



                                          bind-address = 127.0.0.1



                                          and then Restart mysql and you will able to connect that server to this.



                                          Look this you can have idea form that.



                                          this is real sol







                                          share|improve this answer














                                          share|improve this answer



                                          share|improve this answer








                                          edited Feb 4 '14 at 7:38

























                                          answered Feb 4 '14 at 7:31









                                          Krishna

                                          2,25421845




                                          2,25421845







                                          • 3




                                            This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                            – axon
                                            Feb 6 '14 at 18:49










                                          • But this is address which will allow all the Host to get connected to the server na?
                                            – Krishna
                                            Feb 7 '14 at 5:10










                                          • But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                            – Krishna
                                            Feb 7 '14 at 5:11












                                          • 3




                                            This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                            – axon
                                            Feb 6 '14 at 18:49










                                          • But this is address which will allow all the Host to get connected to the server na?
                                            – Krishna
                                            Feb 7 '14 at 5:10










                                          • But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                            – Krishna
                                            Feb 7 '14 at 5:11







                                          3




                                          3




                                          This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                          – axon
                                          Feb 6 '14 at 18:49




                                          This is related, but not the same problem. The error originally received indicates the client is connecting to the MySQL server successfully, but then failing authentication. If bind-address was set to 127.0.0.1, you would get a connection refused error instead.
                                          – axon
                                          Feb 6 '14 at 18:49












                                          But this is address which will allow all the Host to get connected to the server na?
                                          – Krishna
                                          Feb 7 '14 at 5:10




                                          But this is address which will allow all the Host to get connected to the server na?
                                          – Krishna
                                          Feb 7 '14 at 5:10












                                          But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                          – Krishna
                                          Feb 7 '14 at 5:11




                                          But Granting all the permission to the user will not be wise option for that bcoz if u have client user and u are not allowed to create user with all permission then what would be the Solution.?
                                          – Krishna
                                          Feb 7 '14 at 5:11










                                          up vote
                                          1
                                          down vote













                                          If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".






                                          share|improve this answer
























                                            up vote
                                            1
                                            down vote













                                            If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".






                                            share|improve this answer






















                                              up vote
                                              1
                                              down vote










                                              up vote
                                              1
                                              down vote









                                              If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".






                                              share|improve this answer












                                              If you happen to be running on Windows; A simple solution is to run the MySQL server instance configuration wizard. It is in your MYSQL group in the start menu. On the second from last screen click the box that says "allow root access from remote machines".







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Jun 22 '16 at 14:18









                                              Jan

                                              185211




                                              185211




















                                                  up vote
                                                  1
                                                  down vote













                                                  Most of the answers here show you creating users with two host values: one for localhost, and one for %.



                                                  Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use



                                                  CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
                                                  GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;


                                                  and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)






                                                  share|improve this answer
























                                                    up vote
                                                    1
                                                    down vote













                                                    Most of the answers here show you creating users with two host values: one for localhost, and one for %.



                                                    Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use



                                                    CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
                                                    GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;


                                                    and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)






                                                    share|improve this answer






















                                                      up vote
                                                      1
                                                      down vote










                                                      up vote
                                                      1
                                                      down vote









                                                      Most of the answers here show you creating users with two host values: one for localhost, and one for %.



                                                      Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use



                                                      CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
                                                      GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;


                                                      and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)






                                                      share|improve this answer












                                                      Most of the answers here show you creating users with two host values: one for localhost, and one for %.



                                                      Please note that except for a built-in localhost user like root, you don't need to do this. If you simply want to make a new user that can log in from anywhere, you can use



                                                      CREATE USER 'myuser'@'%' IDENTIFIED BY 'mypassword';
                                                      GRANT <whatever privileges are appropriate> ON <relevant tables> TO myuser;


                                                      and it will work just fine. (As others have mentioned, it's a terrible idea to grant administrative privileges to a user from any domain.)







                                                      share|improve this answer












                                                      share|improve this answer



                                                      share|improve this answer










                                                      answered Oct 12 '17 at 21:49









                                                      Erica Kane

                                                      1,7411421




                                                      1,7411421




















                                                          up vote
                                                          1
                                                          down vote













                                                          Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)



                                                          simply go to the target server DB in your control panel, in my case:
                                                          MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
                                                          enter image description here



                                                          I guess there is a similar option on other C.panels like plesk, etc..



                                                          I'm hope it was helpful to you too.






                                                          share|improve this answer
























                                                            up vote
                                                            1
                                                            down vote













                                                            Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)



                                                            simply go to the target server DB in your control panel, in my case:
                                                            MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
                                                            enter image description here



                                                            I guess there is a similar option on other C.panels like plesk, etc..



                                                            I'm hope it was helpful to you too.






                                                            share|improve this answer






















                                                              up vote
                                                              1
                                                              down vote










                                                              up vote
                                                              1
                                                              down vote









                                                              Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)



                                                              simply go to the target server DB in your control panel, in my case:
                                                              MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
                                                              enter image description here



                                                              I guess there is a similar option on other C.panels like plesk, etc..



                                                              I'm hope it was helpful to you too.






                                                              share|improve this answer












                                                              Just find a better way to do that from your hosting control panel (I'm using DirectAdmin here)



                                                              simply go to the target server DB in your control panel, in my case:
                                                              MySQL management -> select your DB -> you will find: "Access Hosts", simply add your remote host here and its working now!
                                                              enter image description here



                                                              I guess there is a similar option on other C.panels like plesk, etc..



                                                              I'm hope it was helpful to you too.







                                                              share|improve this answer












                                                              share|improve this answer



                                                              share|improve this answer










                                                              answered May 19 at 6:35









                                                              Eran Levi

                                                              4021626




                                                              4021626




















                                                                  up vote
                                                                  0
                                                                  down vote













                                                                  On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:



                                                                  I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.



                                                                  So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.






                                                                  share|improve this answer
























                                                                    up vote
                                                                    0
                                                                    down vote













                                                                    On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:



                                                                    I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.



                                                                    So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.






                                                                    share|improve this answer






















                                                                      up vote
                                                                      0
                                                                      down vote










                                                                      up vote
                                                                      0
                                                                      down vote









                                                                      On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:



                                                                      I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.



                                                                      So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.






                                                                      share|improve this answer












                                                                      On the off chance that someone facing this issue is experiencing it from within SQLyog, this happened:



                                                                      I had connected to the remote database (from within SQLyog) and worked for some hours. Afterwards I left the system for some minutes, then came back to continue my work - ERROR 1130 ! Nothing I tried worked; Restarting SQLyog didn't fix it. Then I restarted the system - it still didn't work.



                                                                      So I tried connecting from the terminal - it worked. Then retried it on SQLyog ... and it worked. I can't explain it other than 'random computer quirkiness', but I think it might help someone.







                                                                      share|improve this answer












                                                                      share|improve this answer



                                                                      share|improve this answer










                                                                      answered Jun 13 '15 at 20:48









                                                                      Emmanuel

                                                                      1118




                                                                      1118




















                                                                          up vote
                                                                          0
                                                                          down vote













                                                                          I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel



                                                                          Suppose you are trying to connect database of server B from server A.
                                                                          Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.






                                                                          share|improve this answer


























                                                                            up vote
                                                                            0
                                                                            down vote













                                                                            I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel



                                                                            Suppose you are trying to connect database of server B from server A.
                                                                            Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.






                                                                            share|improve this answer
























                                                                              up vote
                                                                              0
                                                                              down vote










                                                                              up vote
                                                                              0
                                                                              down vote









                                                                              I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel



                                                                              Suppose you are trying to connect database of server B from server A.
                                                                              Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.






                                                                              share|improve this answer














                                                                              I was also facing the same issue. I resolved it in 2 min for me I just white list ip through cpanel



                                                                              Suppose you are trying to connect database of server B from server A.
                                                                              Go to Server B Cpanel->Remote MySQL-> enter Server A IP Address and That's it.







                                                                              share|improve this answer














                                                                              share|improve this answer



                                                                              share|improve this answer








                                                                              edited Jul 12 '16 at 17:58









                                                                              depperm

                                                                              6,43642443




                                                                              6,43642443










                                                                              answered Dec 4 '14 at 22:37









                                                                              user3437729

                                                                              11




                                                                              11




















                                                                                  up vote
                                                                                  0
                                                                                  down vote













                                                                                  Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64.
                                                                                  Mysql refuses connections - period.



                                                                                  Solution:



                                                                                  $ ls -l /var/lib/mysql/mysql/user.*
                                                                                  -rw-rw---- 1 mysql mysql 0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
                                                                                  -rw-rw---- 1 mysql mysql 1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
                                                                                  -rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm


                                                                                  File user.MYD has 0 size (really ?!).
                                                                                  I copied all 3 files from another working system.



                                                                                  $ /usr/sbin/rcmysql stop
                                                                                  $ cd /var/lib/mysql/mysql/
                                                                                  $ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
                                                                                  $ /usr/sbin/rcmysql start
                                                                                  $ cd -
                                                                                  $ mysql -u root -p


                                                                                  I was able to log in. Then, it was just a matter of re-applying all schema privileges.
                                                                                  Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.






                                                                                  share|improve this answer
























                                                                                    up vote
                                                                                    0
                                                                                    down vote













                                                                                    Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64.
                                                                                    Mysql refuses connections - period.



                                                                                    Solution:



                                                                                    $ ls -l /var/lib/mysql/mysql/user.*
                                                                                    -rw-rw---- 1 mysql mysql 0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
                                                                                    -rw-rw---- 1 mysql mysql 1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
                                                                                    -rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm


                                                                                    File user.MYD has 0 size (really ?!).
                                                                                    I copied all 3 files from another working system.



                                                                                    $ /usr/sbin/rcmysql stop
                                                                                    $ cd /var/lib/mysql/mysql/
                                                                                    $ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
                                                                                    $ /usr/sbin/rcmysql start
                                                                                    $ cd -
                                                                                    $ mysql -u root -p


                                                                                    I was able to log in. Then, it was just a matter of re-applying all schema privileges.
                                                                                    Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.






                                                                                    share|improve this answer






















                                                                                      up vote
                                                                                      0
                                                                                      down vote










                                                                                      up vote
                                                                                      0
                                                                                      down vote









                                                                                      Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64.
                                                                                      Mysql refuses connections - period.



                                                                                      Solution:



                                                                                      $ ls -l /var/lib/mysql/mysql/user.*
                                                                                      -rw-rw---- 1 mysql mysql 0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
                                                                                      -rw-rw---- 1 mysql mysql 1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
                                                                                      -rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm


                                                                                      File user.MYD has 0 size (really ?!).
                                                                                      I copied all 3 files from another working system.



                                                                                      $ /usr/sbin/rcmysql stop
                                                                                      $ cd /var/lib/mysql/mysql/
                                                                                      $ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
                                                                                      $ /usr/sbin/rcmysql start
                                                                                      $ cd -
                                                                                      $ mysql -u root -p


                                                                                      I was able to log in. Then, it was just a matter of re-applying all schema privileges.
                                                                                      Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.






                                                                                      share|improve this answer












                                                                                      Problem: root@localhost is unable to connect to a fresh installation of mysql-community-server on openSUSE 42.2-1.150.x86_64.
                                                                                      Mysql refuses connections - period.



                                                                                      Solution:



                                                                                      $ ls -l /var/lib/mysql/mysql/user.*
                                                                                      -rw-rw---- 1 mysql mysql 0 Apr 29 19:44 /var/lib/mysql/mysql/user.MYD
                                                                                      -rw-rw---- 1 mysql mysql 1024 Apr 29 19:44 /var/lib/mysql/mysql/user.MYI
                                                                                      -rw-rw---- 1 mysql mysql 10684 Apr 29 19:44 /var/lib/mysql/mysql/user.frm


                                                                                      File user.MYD has 0 size (really ?!).
                                                                                      I copied all 3 files from another working system.



                                                                                      $ /usr/sbin/rcmysql stop
                                                                                      $ cd /var/lib/mysql/mysql/
                                                                                      $ scp root@othersytem:/var/lib/mysql/mysql/user.* ./
                                                                                      $ /usr/sbin/rcmysql start
                                                                                      $ cd -
                                                                                      $ mysql -u root -p


                                                                                      I was able to log in. Then, it was just a matter of re-applying all schema privileges.
                                                                                      Also, if you disabled IPv6, re-enable it temporary so that root@::1 account can also work.







                                                                                      share|improve this answer












                                                                                      share|improve this answer



                                                                                      share|improve this answer










                                                                                      answered Apr 30 at 3:43









                                                                                      Alex D

                                                                                      213




                                                                                      213




















                                                                                          up vote
                                                                                          0
                                                                                          down vote













                                                                                          This answer might help someone...



                                                                                          All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)



                                                                                          I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!






                                                                                          share|improve this answer
























                                                                                            up vote
                                                                                            0
                                                                                            down vote













                                                                                            This answer might help someone...



                                                                                            All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)



                                                                                            I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!






                                                                                            share|improve this answer






















                                                                                              up vote
                                                                                              0
                                                                                              down vote










                                                                                              up vote
                                                                                              0
                                                                                              down vote









                                                                                              This answer might help someone...



                                                                                              All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)



                                                                                              I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!






                                                                                              share|improve this answer












                                                                                              This answer might help someone...



                                                                                              All these answers didnt help, then I realised I forgot to check one crucial thing.. The port :)



                                                                                              I have mysql running in a docker container running on a different port. I was pointing to my host machine on port 3306, which I have a mysql server running on. My container exposes the server on port 33060. So all this time, i was looking at the wrong server! doh!







                                                                                              share|improve this answer












                                                                                              share|improve this answer



                                                                                              share|improve this answer










                                                                                              answered May 16 at 22:21









                                                                                              Srini

                                                                                              33129




                                                                                              33129




















                                                                                                  up vote
                                                                                                  0
                                                                                                  down vote













                                                                                                  Simple way:



                                                                                                  Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 


                                                                                                  then



                                                                                                  FLUSH PRIVILEGES;


                                                                                                  done!






                                                                                                  share|improve this answer
























                                                                                                    up vote
                                                                                                    0
                                                                                                    down vote













                                                                                                    Simple way:



                                                                                                    Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 


                                                                                                    then



                                                                                                    FLUSH PRIVILEGES;


                                                                                                    done!






                                                                                                    share|improve this answer






















                                                                                                      up vote
                                                                                                      0
                                                                                                      down vote










                                                                                                      up vote
                                                                                                      0
                                                                                                      down vote









                                                                                                      Simple way:



                                                                                                      Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 


                                                                                                      then



                                                                                                      FLUSH PRIVILEGES;


                                                                                                      done!






                                                                                                      share|improve this answer












                                                                                                      Simple way:



                                                                                                      Grant All Privileges ON *.* to 'USER_NAME'@'%' Identified By 'YOUR_PASSWORD'; 


                                                                                                      then



                                                                                                      FLUSH PRIVILEGES;


                                                                                                      done!







                                                                                                      share|improve this answer












                                                                                                      share|improve this answer



                                                                                                      share|improve this answer










                                                                                                      answered yesterday









                                                                                                      user5510975

                                                                                                      317517




                                                                                                      317517




















                                                                                                          up vote
                                                                                                          -1
                                                                                                          down vote













                                                                                                          if you are trying to execute mysql query withouth defining connectionstring, you will get this error.



                                                                                                          Probably you forgat to define connection string before execution. have you check this out?
                                                                                                          (sorry for bad english)






                                                                                                          share|improve this answer
























                                                                                                            up vote
                                                                                                            -1
                                                                                                            down vote













                                                                                                            if you are trying to execute mysql query withouth defining connectionstring, you will get this error.



                                                                                                            Probably you forgat to define connection string before execution. have you check this out?
                                                                                                            (sorry for bad english)






                                                                                                            share|improve this answer






















                                                                                                              up vote
                                                                                                              -1
                                                                                                              down vote










                                                                                                              up vote
                                                                                                              -1
                                                                                                              down vote









                                                                                                              if you are trying to execute mysql query withouth defining connectionstring, you will get this error.



                                                                                                              Probably you forgat to define connection string before execution. have you check this out?
                                                                                                              (sorry for bad english)






                                                                                                              share|improve this answer












                                                                                                              if you are trying to execute mysql query withouth defining connectionstring, you will get this error.



                                                                                                              Probably you forgat to define connection string before execution. have you check this out?
                                                                                                              (sorry for bad english)







                                                                                                              share|improve this answer












                                                                                                              share|improve this answer



                                                                                                              share|improve this answer










                                                                                                              answered Aug 31 '15 at 7:17









                                                                                                              Ali CAKIL

                                                                                                              46213




                                                                                                              46213




















                                                                                                                  up vote
                                                                                                                  -1
                                                                                                                  down vote













                                                                                                                  All of the answers here didn't work in my case so I guest this may help other users in the future. This can also be a problem in our code, not just in MySQL alone.



                                                                                                                  If you are using VB.NET



                                                                                                                  Instead of this code:



                                                                                                                   Dim server As String = My.Settings.DB_Server
                                                                                                                  Dim username As String = My.Settings.DB_Username
                                                                                                                  Dim password As String = My.Settings.DB_Password
                                                                                                                  Dim database As String = My.Settings.DB_Database

                                                                                                                  MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                  & "user id=" & username & ";" _
                                                                                                                  & "password=" & password & ";" _
                                                                                                                  & "database=" & database

                                                                                                                  MysqlConn = New MySqlConnection()


                                                                                                                  You need to move MysqlConn = New MySqlConnection() on the first line. So it would be like this



                                                                                                                   MysqlConn = New MySqlConnection()

                                                                                                                  Dim server As String = My.Settings.DB_Server
                                                                                                                  Dim username As String = My.Settings.DB_Username
                                                                                                                  Dim password As String = My.Settings.DB_Password
                                                                                                                  Dim database As String = My.Settings.DB_Database

                                                                                                                  MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                  & "user id=" & username & ";" _
                                                                                                                  & "password=" & password & ";" _
                                                                                                                  & "database=" & database





                                                                                                                  share|improve this answer


























                                                                                                                    up vote
                                                                                                                    -1
                                                                                                                    down vote













                                                                                                                    All of the answers here didn't work in my case so I guest this may help other users in the future. This can also be a problem in our code, not just in MySQL alone.



                                                                                                                    If you are using VB.NET



                                                                                                                    Instead of this code:



                                                                                                                     Dim server As String = My.Settings.DB_Server
                                                                                                                    Dim username As String = My.Settings.DB_Username
                                                                                                                    Dim password As String = My.Settings.DB_Password
                                                                                                                    Dim database As String = My.Settings.DB_Database

                                                                                                                    MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                    & "user id=" & username & ";" _
                                                                                                                    & "password=" & password & ";" _
                                                                                                                    & "database=" & database

                                                                                                                    MysqlConn = New MySqlConnection()


                                                                                                                    You need to move MysqlConn = New MySqlConnection() on the first line. So it would be like this



                                                                                                                     MysqlConn = New MySqlConnection()

                                                                                                                    Dim server As String = My.Settings.DB_Server
                                                                                                                    Dim username As String = My.Settings.DB_Username
                                                                                                                    Dim password As String = My.Settings.DB_Password
                                                                                                                    Dim database As String = My.Settings.DB_Database

                                                                                                                    MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                    & "user id=" & username & ";" _
                                                                                                                    & "password=" & password & ";" _
                                                                                                                    & "database=" & database





                                                                                                                    share|improve this answer
























                                                                                                                      up vote
                                                                                                                      -1
                                                                                                                      down vote










                                                                                                                      up vote
                                                                                                                      -1
                                                                                                                      down vote









                                                                                                                      All of the answers here didn't work in my case so I guest this may help other users in the future. This can also be a problem in our code, not just in MySQL alone.



                                                                                                                      If you are using VB.NET



                                                                                                                      Instead of this code:



                                                                                                                       Dim server As String = My.Settings.DB_Server
                                                                                                                      Dim username As String = My.Settings.DB_Username
                                                                                                                      Dim password As String = My.Settings.DB_Password
                                                                                                                      Dim database As String = My.Settings.DB_Database

                                                                                                                      MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                      & "user id=" & username & ";" _
                                                                                                                      & "password=" & password & ";" _
                                                                                                                      & "database=" & database

                                                                                                                      MysqlConn = New MySqlConnection()


                                                                                                                      You need to move MysqlConn = New MySqlConnection() on the first line. So it would be like this



                                                                                                                       MysqlConn = New MySqlConnection()

                                                                                                                      Dim server As String = My.Settings.DB_Server
                                                                                                                      Dim username As String = My.Settings.DB_Username
                                                                                                                      Dim password As String = My.Settings.DB_Password
                                                                                                                      Dim database As String = My.Settings.DB_Database

                                                                                                                      MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                      & "user id=" & username & ";" _
                                                                                                                      & "password=" & password & ";" _
                                                                                                                      & "database=" & database





                                                                                                                      share|improve this answer














                                                                                                                      All of the answers here didn't work in my case so I guest this may help other users in the future. This can also be a problem in our code, not just in MySQL alone.



                                                                                                                      If you are using VB.NET



                                                                                                                      Instead of this code:



                                                                                                                       Dim server As String = My.Settings.DB_Server
                                                                                                                      Dim username As String = My.Settings.DB_Username
                                                                                                                      Dim password As String = My.Settings.DB_Password
                                                                                                                      Dim database As String = My.Settings.DB_Database

                                                                                                                      MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                      & "user id=" & username & ";" _
                                                                                                                      & "password=" & password & ";" _
                                                                                                                      & "database=" & database

                                                                                                                      MysqlConn = New MySqlConnection()


                                                                                                                      You need to move MysqlConn = New MySqlConnection() on the first line. So it would be like this



                                                                                                                       MysqlConn = New MySqlConnection()

                                                                                                                      Dim server As String = My.Settings.DB_Server
                                                                                                                      Dim username As String = My.Settings.DB_Username
                                                                                                                      Dim password As String = My.Settings.DB_Password
                                                                                                                      Dim database As String = My.Settings.DB_Database

                                                                                                                      MysqlConn.ConnectionString = "server=" & server & ";" _
                                                                                                                      & "user id=" & username & ";" _
                                                                                                                      & "password=" & password & ";" _
                                                                                                                      & "database=" & database






                                                                                                                      share|improve this answer














                                                                                                                      share|improve this answer



                                                                                                                      share|improve this answer








                                                                                                                      edited Sep 3 '15 at 8:52

























                                                                                                                      answered Jul 21 '15 at 5:14









                                                                                                                      Cary Bondoc

                                                                                                                      1,78312743




                                                                                                                      1,78312743















                                                                                                                          protected by cimmanon Dec 2 '15 at 22:34



                                                                                                                          Thank you for your interest in this question.
                                                                                                                          Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).



                                                                                                                          Would you like to answer one of these unanswered questions instead?



                                                                                                                          Popular posts from this blog

                                                                                                                          Use pre created SQLite database for Android project in kotlin

                                                                                                                          Darth Vader #20

                                                                                                                          Ondo