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.
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
Related
i am new at AWS lightsail, basically just following the instruction step by step create a instance, create a database named mypost, and upload all file to instance by filezilla, and then use potty to connect phpmyadmin, export local database into online database, but somehow when i test the link on browser it tell me Connection Error: SQLSTATE[HY000] [1049] Unknown database 'mypost' , i checked both phpmyadmin and database in the aws console all named mypost, i also switched to public mode as well, anyone know why is it?
In my project I want to create console commands for dropping and creating DB, just like in Symfony2 like database creation command in laravel console? The way described in the answer to that question works fine for dropping DB, but when I try to create it with this code:
$dbType = \Config::get('database.default');
$dbName = \Config::get('database.connections')[$dbType]['database'];
\DB::statement("CREATE DATABASE `$dbName`");
I get an exception: SQLSTATE[42000] [1049] Unknown database 'my_awesome_db_name'. Any ideas?
Laravel is trying to connect to MySQL and select the database my_awesome_db_name. This isn't possible, because that database name doesn't exist yet (you haven't created it), so MySQL fails on the internal USE my_awesome_db_name command.
I'm trying to install a php script locally on IIS.
I've gotten to the point where I need to fill in my database information.
I've connected to another database through visual studio, here's the connection string:
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\TaskSubmitter.mdf;Initial Catalog=TaskSubmitter;Integrated Security=False; User Id=sa; Password=thepassword"
Now I've created a database named "pligg" for the php script.
The information I've filled in is the following:
Database name: pligg
Database username: sa
Database password: thepassword
Database server: (LocalDb)\v11.0
Table prefix: _pligg
However I get an error when trying to connect through the script.
The script is working fine so I'm sure I've done something wrong regarding the settings or the database.
Anyone know what could be wrong?
Where is mistake? I try to connect to database from php script. I am getting the error that database is unknown. Database for sure exists, i can see this from PhpMyAdmin.
I use XAMPP v3.2.1 with mysqlnd 5.0.11-dev and php v5.5.9.
Script file debug1.php in folder c:\xampp\htdocs:
$conn=mysqli_connect( 'localhost', 'root', '', $vdbname ) or die( "cannot connect to server".mysqli_error() );
When i run this file from browser windows using url: "localhost/debug1.php" i am getting error message:
Warning: mysqli_connect(): (HY000/1049): Unknown database 'gintare_calendar' in C:\xampp\htdocs\debug1DBconn.php on line 5
You may want to look for whitespace in database name. From phpMyAdmin go to database Operation sections and see if white space has been added in front or after database name.
This means the database you want to connect to is not called "gintare_calendar".
Open your MySQL administration package (phpmyadmin) and verify the actual name of the database you want to connect to.
I am sorry, i forget that i reinstalled XAMPP. It is true. There is no database. I have to create the database, import previous tables and than everything works again.
I just used artisan migrate to create some table, but I get an error of Type PDO:
[PDOException]
SQLSTATE[HY000] [1045] Access denied for user 'root'#'localhost' (using password: NO)
A php/mysql testscript could connect to the database just fine, but it was another virtualhost and it did not use PDO.
In Laravel4 edited app/config/local/database.php to set the password and database name.
edit in start.php
UPDATE
I hardcoded the password in the PDO connection array and now terminal says there is no database named "database". Clearly it is looking somewhere else for the config, but I have no other config file.
(Due to following a tutorial about making a "local" directory it was not working for me)As it stands, I have downloaded the stable version and everything is working great.
I am going to delete this post, to keep the forum clean.
Make sure you have set up your database connection correctly in app/config/database
Laravel Database Docs
Make sure you are setting up a 'local' environment in start.php
Otherwise Laravel will look for DB config in app/config/database.php
Kindly Check Your app/config/database.php file in local host.
1.)Make Sure local Host Data Base name is Correct
2.)Make sure local Host Data Base username is correct.
3.)Make sure local Host Data Base password is correct.