Artisan says database not found - database

I'm working on a brand new laravel application for learning laravel.
I've done the following (I'm following this tutorial):
Created new application using laravel new test_project_2
Setup the .env file
Created a database called laravel
Run php artisan migrate
This is my .env file:
This is what I get:
As you can see, I can use the "laravel" database perfectly well when I'm logged into Mariadb via terminal. The website also renders absolutely fine. I did run the SQL command - SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE' but I got the message ERROR 1054 (42S22): Unknown column 'laravel' in 'where clause'
Note - I've worked on other dummy laravel projects last week and didn't face any problems, although admittedly I'm not sure if I ran the php artisan migrate command for those (wasn't required, but I might have run it just cause I kept seeing it).
Why is this problem happening?
How do I fix it?

Run the below command and try migrate command
php artisan cache:clear
php artisan config:clear

can you try creating your database with below and then try migration.
mysql -u root -p
create database [DB name];
use [DB name];
Then do migration:
php artisan migrate
Also make sure you have entered correct database name & credential.

Solved this by changing the DB_HOST values from 127.0.0.1 to localhost.
Anyone know why this works? Beats the heck out of me.

Related

Laravel sql server on mac

So i installed SQL serve with docker on mac and i can actually manage to access my local sql server database with datagrip, but when i want to do a php artisan migrate i get this error:
[Illuminate\Database\QueryException] could not find driver (SQL: select * from sysobjects where type = 'U' and name = migrations)
and this error
[PDOException]could not find driver
i search for some answer but they where mostly for linux.
So i manage to installed al the necessary drivers just by installing this:
https://github.com/Microsoft/msphpsql/releases
php and Laravel worked perfectly after i installed those package and added this lines on my php.ini file:
extension=sqlsrv.so
extension=pdo_sqlsrv.so
You need a module called "pdo_mysql". Try php_info()to see if it's installed - I doubt it's there.
In your php.ini file (you can find it via php --ini) uncomment the line which has extension=pdo_mysql.so on it and restart the server.
edit: also make sure that the default key is set in your config/database.php file. Something like 'default' => env('DB_CONNECTION', 'mysql'),

wamp phpinfo shows sqlsrv but phpinfo inside artisan server not showing sqlsrv drivers

I am using Apache 2.4.23 and Php 7.0.10 and Laravel 5.4.
I have installed sqlsrv and it's pdo file inside 'C:\wamp64\bin\php\php7.0.10' directory.
So when I created and test.php file in the www directory and executed it I got the following info.
The PDO Information
the SQLSRV info:
But when I start php artisan serve and execute phpinfo() then I didn't get the SQL drivers.
PDO extensions:
Drives SQL
So when I try to connect to SQL db I am getting this error.
QueryException in Connection.php line 647:
could not find driver (SQL: SELECT TOP 5 ......
Any help will be appreciated.
Thanks
WAMPServer has 2 php.ini files. If you want to add the SQLServer extension for use from the command line CLI then you must manually edit the
c:\wamp\bin\php\php7.0.10\php.ini
and add the new extension line
The extension dll's should be placed in the
c:\wamp\bin\php\php7.0.10\ext
folder.

Heroku. Django. South. Database column does not exist

I am new to Heroku. I just migrated my django models using south:
sudo heroku run python manage.py migrate
I get the message "Nothing to migrate" in all of my six apps.
Then when I try to visit the website I get the error:
ProgrammingError "column X does not exist".
Everything works fine locally. What should I do, drop the database and recreate it again? If that is the answer, how do I do that on Heroku?
Thanks for you help.
To drop the database on heroku, run:
heroku pg:psql
as per https://devcenter.heroku.com/articles/heroku-postgresql#pg-psql.
Then do:
drop database <database name>;
create database <database name>;
Then you can try and run your migrations again.

Mysql error when using Cake Bake

H,
I am a newbie to cake php. So there is a problem i'm facing with.
I have installed XAMPP and my cakephp project folder lies in htdocs(/opt/lampp/htdocs/cakephp). When I start cake bake by the command /.cake bake, I am getting a mysql error as below.
enter code here
PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /opt/lampp/htdocs/cakephp/cake/libs/model/datasources/dbo/dbo_mysql.php on line 552
can u help me?
Check if you have MySQL installed properly.
With XAMPP normally get this error.
You can do two things to solve it:
A clean installation of Apache + PHP + MySQL
If you're on a linux or on a mac you can create a symbolic link to the socket:
ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock
Where /tmp/ is your XAMPP mysql folder (e.g. /opt/lampp/var/mysql/mysql.sock)

How to completely dump the data for Django-CMS

I have an instance of Django-CMS already running in a production environment. I would like to dump all the data related to the CMS (PAGES and PLUGINS) so that I may load it back into my development environment.
When I do python manage.py dumpdata cms it dumps most of the data, but not all of it. None of the content for the plugins is dumped. When I look at the django-cms source, I see that the plugins are organized in a different folder than the rest of the models - I'm sure this has something to do with the behavior of dumpdata.
Does anyone know how they would achieve what I am trying to do?
Thanks for your help/answers!
Django's built in dump and restore commands work well for migrating the contents of the CMS.
To dump the contents of the CMS, you need to include both the cms app as well as each of the plugin types you are using in the dumpdata command, so something like:
manage.py dumpdata cms text picture link file [other plugin types] > cms_export.json
to dump your content (you just need the app name, not the full path, like cms.plugins.text).
Here's an update to the procedure I use:
./manage.py dumpdata >fixtures/all.json
psql
DROP DATABASE [DBNAME];
createdb -T template_postgis [DBNAME]
./manage.py syncdb
psql [DBNAME]
delete from auth_group_permissions; delete from auth_permission; delete from django_admin_log; delete from django_content_type;
If you don't delete the tables above you'll get this error when loading the fixtures:
IntegrityError: duplicate key value violates unique constraint django_content_type_app_label_key
And then:
./manage.py loaddata fixtures/all.json
Philipp
For DjangoCMS 3.0, the syntax is the same but the names of the plugins have all changed. To get all standard plugins:
./manage.py dumpdata cms djangocms_column djangocms_file djangocms_flash djangocms_googlemap djangocms_inherit djangocms_link djangocms_picture djangocms_style djangocms_teaser djangocms_text_ckeditor djangocms_video > cms_export.json
Your dumpdata command only dumps the data for the cms app, but each plugin (cms.plugins.text, cms.plugins.picture, etc.) is its own app, and so needs to be added to the command line.

Resources