0

When I launch the website through local host, I get the following error:

Database Error: Unknown database 'db_name'

I'm having a dig around as to what the problem is. The website belongs to a friend of mine and he wants me to connect the website to the database. The database resides within the root directory. I'm merely trying to connect to it.

In most of the PHP files, there is a tag that includes the config file which contains the details of the database.

Any ideas as to how I can get it working and resolve the Database Error: Unknown database 'db_name' error?

Any help is highly appreciated.

9
  • 1
    Which website? Show us the part where you etablish the connection to the db. Commented Aug 2, 2012 at 13:08
  • 1
    What do you mean by the database resides in the root directory? Commented Aug 2, 2012 at 13:08
  • What do you mean the database resides in the root directory? MySQL is a database server, not a file. Commented Aug 2, 2012 at 13:08
  • If you are using PDO you need to specify the database name in the connection string. Are you sure that the database matches the name? Linux systems are case sensetive. Commented Aug 2, 2012 at 13:09
  • @Fluffeh somehow I severely doubt this code is using PDO... Commented Aug 2, 2012 at 13:09

1 Answer 1

1

Database should not reside in root directory, it should be imported to database (Mysql) server.

Check in Mysql databases, does your database resides there? If not, you can do so by phpMyAdmin or navigating to your mysql and importing it.

Create database in mysql and import the sql file as below by opening command-line terminal:

/path/to/mysql/bin > mysql -u username -p < /path/to/root/db.sql

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.