MYSQL INSERT fails to insert

Discussion in 'Databases' started by BarclayVision, Jun 14, 2014.

  1. I get the following error when I try to INSERT a record into a simple test DB (MYSQL):

    Failed to connect to MySQL: Access denied for user 'barclay'@'%' to database 'hospitals'

    I can do a SELECT and records are returned and I have checked syntax on other DB's - seems to be a permission problem, but my DB was created on DiscountASP.net MySQLWorkbench (can't seem to set permissions from there?)

    here is code:
    <?php
    $con=mysqli_connect("mysql502.discountasp.net","barclay","mypassword","hospitals");
    if (mysqli_connect_errno()) {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }

    mysqli_query($con,"INSERT INTO users (UserName, Password, Email) VALUES ('testuser', 'password', '[email protected]')");

    mysqli_close($con);
    ?>
     
  2. martino

    martino DiscountASP.NET Staff

    Looks like you're using a different MySQL database according to the error message you're getting. Unless you renamed the database name to censer the real database name for your post.

    If you did censor the out the real MySQL database name.

    Sounds like your MySQL Database got full because you didn't assigned it enough disk space. To resolve your issue you will need to increase the MySQL Disk space through the control panel in the MySQL Database Manager Section. Click on Manage next to the MySQL database. Click on Update Quota and increase the amount.

    Wait about an hour for our system to resign the permissions back to the MYSQL database.

    When a MySQL disk space gets full. You will lose the Insert/Update permissions until you increase the disk space on the database through the control panel and then allow the system to reassign the permissions.
     
  3. Actually you were on to the problem, I was trying to use the <my db name> I created but not the actual full db name from discountasp.net like:
    Mysql502_8675309_<my db name>
     
  4. martino

    martino DiscountASP.NET Staff

    You need to make sure you use the database name for the MySQL base you have hosted with us. If you try to use a different a different name in your code. It will fail because it doesn't exist on the MySQL Server thus your user doesn't have permissions for a MySQL database that doesn't exist.
     

Share This Page