1. Startseite
  2. MySQL
  3. Datenbank-Import schläg fehl: CREATE DATABASE-Zeile

Datenbank-Import schläg fehl: CREATE DATABASE-Zeile

Übersicht

Restoring a database backup within the control panel, mysqli CLI, or phpMyAdmin may fail with the following message:

#1044 – Access denied for user ‘myuser’@’localhost’ to database ‘mynewdb’

Ursache

A CREATE DATABASE query is issued during database import that cannot succeed due to limited permissions. All databases must be created within the Bedienfeld to ensure proper account namespacing is applied.

Lösung

First create the destination database within the control panel.  Next, remove the lines that begin with: CREATE DATABASE und USE. These lines normally occur consecutively.

CREATE DATABASE IF NOT EXISTS `mynewdb` /*!40100 DEFAULT CHARACTER SET utf8mb4 */;
USE `mynewdb`

becomes:

<empty>

When importing a database in phpMyAdmin select the database in the left panel, then select Import from the tabs in the right panel.

When importing in mysql from the Terminal, include the database name, e.g.

mysql -u username -ppassword mynewdb < dbbackup.sql
Aktualisiert am März 7, 2021

Verwandte Artikel