Creating a database in Laravel - mysql

Forgive me if this is a silly question, just been scratching my head for hours on this and cannot find a decent answer!
I'm writing a script to install a Laravel CMS to a database and would like to have it create the database from the given name if it does not exist.
I am at the stage where the system understands that the database does not exist and so needs to create it, But every time I run my code I get the exception:
SQLSTATE[HY000] [1049] Unknown database 'mytesting' (SQL: CREATE DATABASE mytesting)
I'm running the code as follows to initiate the database creation:
DB::statement(DB::raw('CREATE DATABASE '.$_POST['DbDatabase']));
Now, I can understand that this may be crashing because the database name set in the .env is that of a database that is yet to exist, but I am wondering if there is a way to have the system simply auth to MySQL via login (No db name specified) and then create the table?
I've run the provided sql inside Sequel pro and it works there so I know it's valid, But am confused all the same!
If any yall could shine some light on this I'd be eternally grateful!
Thanks guys <3

I finally managed to figure out a way around this!
So instead of using Laravel's DB manager I ended up using a PDO instance instead as I could control what it did at a much more granular level. I specified the connection details out of the env file.
Thanks so much for your help guys <3

Related

MySQL strange behaviour: "b'schemaname'" schema is created

this is my frist time posting something like this but im pulling my hair our, for days on end i have been trying to debug and find what is wrong with mysql, i run a gameserver and use mysql to store all the players information, like items, clothes etc, i recently came into this issue, i can no longer run sql scripts, when i try an error is thrown and a new schema is created with the name of the current schema im trying to run the script in, but it creates it like this b'schemaname' (schemaname being what the name of my schema is that im trying to run the script on), now i have reinstalled mysql and to no luck the issue still persists, i have included a video to show exactly what i mean and what is happening. ----> https://youtu.be/l6o4r5jtpcU <------ I appreciate every and anyone that helps, its not too big of an issue as i can still run the scripts a different way but still, i have no idea what has caused this or a fix for it, thank you

How to create a DB in MySql at run time from VB?

Good morning,
I'm developing a cms.
Before I was working with Access but I was limited so now I'm changing to MySql and I have some problems about the creation at run time of the db.
When I was using Access I connected with OLEDB and I used the object Adox to develop on the fly databases.
Now I don't know how to do, I found a lot of articles for Sql Server but nothing interesting for MySql.
Is it possbile to do it?
When I connect I must to put the name of db but I dont have yet.. so..
Anyone has already developed something similar?
Thank you

Connecting to SQL Server with SQuirrel SQL

I am in the process of learning more about database manipulation. I downloaded SQuirrel since it seemed like a good place to start. I know quite a bit about SQL and databases already due to an internship I had last summer but know absolutely NOTHING about networking so I am having a tough time getting a database set up and created.
I set up the JDBC driver and everything but when it comes down to creating an Alias I am having a hard time figuring out where to go. So far I have:
jdbc:sqlserver\localhost; create=true
for the URL but I keep getting SQL exceptions. If there is anybody out there who has the patience and the ability to explain how to get started I would greatly appreciated it.
create is not a valid connection property. The valid properties are here: SQL Server JDBC connection properties.
You should also include databaseName and instanceName in your JDBC connection url.

How to load and execute query log on mysql server?

Hi i'm new on this site and i thank you all right now for the help you guys are hopefully going to give me. I am also new to the mysql enviroment. So, i have been told by my professor to find some tools which given in input log files (general or slow query) reproduces on a mysql server all the queries such as select, delete, update and insert. The tool should possibly be multi-threaded. I found something like mysql workbench or mk-log-player but i'm not sure if that is what i am looking for since as i have told before i'm new in the mysql enviroment.
I think You want Sql client for using Mysql
use SQL-yog client it is good for multiple connections to database.
you can download it from here
http://code.google.com/p/sqlyog/downloads/list

Rails find not returning a record that exists in the database

This is a weird thing I've been encountering and I was wondering if people could give me a few pointers on where to look for problems.
What I'm doing is running a find for an id on a model. When I run it on a certain set of records, they return that record, as expected. But there's another 100 records or so, that I can see in the database (mysql), but running a find command returns an ActiveRecord::RecordNotFound exception.
If I create another record directly in the database, I cannot pull up that record either. However, if I do a new command in the rails console, that record is retrievable. If I do a find_by_sql command, the records are retrievable.
I've tried optimizing the table, but beyond that, I'm kind of stumped as to what would be causing this. I'm running Rails 2.3.12 with Ruby 1.8.7 and the mysql gem on my local machine. Any thoughts on possible causes would be greatly appreciated. Thanks!
Edit Thanks for the pointers - attached a logger to my console instance, which exposed the problem - a forgotten default_scope which was restricting what was returned.
There must be something in your model that restraint the scope of your SQL queries.
Check the log for SQL produced by your Ruby code and you will find useful hints on what's going wrong.