مشکل شما در اینجا مطرح شد:
#1044 – Access denied for user ‘username’@'localhost’ to database ‘database_name’
To get around this problem and to complete importing your database to your new host do the following:
Login to your cPanel and click on ‘MySQL Databases’.
Create a new database with your preferred name (I am going to use the name ‘newDB‘ for easy reference. You should have privilege to create a new database through this MySQL Database panel even though you don’t have privilege to create new database through phpMyAdmin).
Open the sql database file that you are using for importing (e.g. ‘localhost.sql‘) in a text editor such as notepad.
Search for the text “CREATE DATABASE”
Delete this line containing the create database command.
In the next line change the database name (tips_tricks in this case) to the newly created database (newDB) in step2 after the word ‘USE’.
Now use the import wizard from phpMyAdmin to import the database and it will use the already created database to import all the tables without any problem.
1- رفتن به مدیریت دیتابیس
2- ساخت دیتابیسی جدید
3- بازکردن فایل بکآپ در ادیتور متن
4- جستجو برای CREATE DATABASE
5- حذف این خط و دستور آن
6- در خط بعدی تغییر نام دیتابیس قدیمی به دیتابیس جدید. بعد از واژه 'USE'
7- اکنون میتوانید فایل بکآپ را ایمپورت کنید
Example of the sql database file before modifying
–
– Database: tips_tricks
–
CREATE DATABASE tips_tricks
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE tips_tricks
;
Example of the sql database file after modifying
CREATE DATABASE applewoo_applewood
DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;
USE newDB
;
Alternatively, you could request your web hosting provider to add database creation privilege to your phpMyAdmin.
Hope this will help anyone having a similar problem. Feel free to share your thoughts by leaving comments in the comment area below.