title: Excel VBA connecting to remote MySQL Database
body: <p>i am using the OBDC connector to use VBA to connect to my MySQL database. It currently runs on a local webserver (localhost) but is accessible from other PCs on the network via my PC's IP address.</p>
  
  <p>In my connection function I had <code>localhost</code> as the location but when I change it to my IP address I get an </p>
  
  <blockquote>
    <blockquote>
      <p><code>[MySQL][ODBC 5.2 Driver] (my computer name) is not allowed to connect to this MySQL server</code></p>
    </blockquote>
  </blockquote>
  
  <p>error.</p>
  
  <p>I presume this is a security problem. Any way to fix this?</p>
  
  <p>Here is my connection function:</p>
  
  <pre><code>Public Function OpenConnection() As ADODB.connection
      //This function requires the "Microsoft ActiveX Data Objects" Library (Choose v2.8 from references for compatibility across Office versions)
  
      Dim source As String, location As String, user As String, password As String
      source = "MySQL"
      location = "192.168.1.60"
      user = "root"
      password = ""
      database = "database name"
      mysql_driver = "MySQL ODBC 5.2 ANSI Driver"
  
      //Build the connection string
      Dim connectionString As String
  
      connectionString = "Driver={" &amp; mysql_driver &amp; "};Server=" &amp; location &amp; ";Database=" &amp; database &amp; ";UID=" &amp; user &amp; ";PWD=" &amp; password
  
      //Create and open a new connection to the selected source
      Set OpenConnection = New ADODB.connection
      OpenConnection.CursorLocation = adUseClient
      Call OpenConnection.Open(connectionString)
  End Function
  </code></pre>