How to see my laravel database? - database

I've set functional laravel project, database connection works, I've added some tables via terminal but now I'd like to see it just as you can see everything with phpmyadmin, for example. How to locate the database file and how to open it, by default?

In Terminal:
cd into Project directory
vagrant ssh
cd into Project directory in machine
mysql -u[username] -p[password] - e.g mysql -uhomestead -psecret
Vaala! You are connected to MySQL...
SHOW databases;
USE [Database Name]; - e.g use Homestead;
SHOW TABLES; to see all tables
SELECT * from [table]; - e.g select * from users

Are you using MySQL? If so, you can install the MySQL Workbench and enter the same database credentials to view your data similar to PHPMyAdmin. Alternatively, you can install PHPMyAdmin wherever you are developing (local machine/vagrant/remote). You can also view everything in tabular format with the command line and mysql as well, but it's not very friendly.

Related

creating database without coding

I want to create a localhost database that allows me to enters data easily without coding.
For example, I want to create books database that stores: title, price, and publisher.And I want to enter data manually just like we are entering it in Excel. I mean without coding.
do you have any suggestions?
You can install Xampp
Xampp is one of my favorite Apache Local Server
Then, activate the sql, and enter to MyPhpAdmin
If you want Client Database, you can comfortably install MySql Workbench
This's localhost Cient database UI and much better if you want to create only database work.
Install phpMyAdmin
Start it in server mode
create a table with all the columns - title, price, and publisher
You are good to go

How to populate a heroku postgresql database with a sql file

First of, I want to say, that I am not a DB expert and I have no experience with the heroku service.
I want to deploy a play framework application to the heroku service. And I need a database to do so. So I created a postgresql database with this command, since it's supported by heroku:
Users-MacBook-Air:~ user$ heroku addons:create heroku-postgresql -a name_of_app
And I got this as response
Creating heroku-postgresql on ⬢ benchmarkingsoccerclubs... free
Database has been created and is available
! This database is empty. If upgrading, you can transfer
! data from another database with pg:copy
So the DB is now existing but empty of course. For development I worked with a local H2 Database.
Now I would want to populate the DB on heroku using a sql file, since it's quite a lot of data. But I couldn't find how to do that. Is there a command for the heroku CLI, where I can hand over the sql file as an argument and it populates the database? The File basically consists of a few tables which get created and around 10000 Insert commands.
EDIT: I also have CSV files from all the tables. So if there is a way how I can populate the Postgres DB with those would be also great
First, run the following to get your database's name
heroku pg:info --app <name_of_app>
In the output, note the value of "Add-on", which should look something like this:
Add-on: postgresql-angular-12345
Then, issue the following command:
heroku pg:psql <Add-on> --app <name_of_app> < my_sql_file.sql
For example (assuming your sql commands are in file test.sql):
heroku pg:psql postgresql-angular-12345 --app my_cool_app < test.sql

Can't select database - Wordpress

When I download a new wordpress from wordpress.org and then paste it into my www folder of WAMP, then create a new database in phpmyadmin, then go to localhost and click the wordpress site, it asks to create the config file, and enter the database details, and i do that correctly, but when I click submit, it says "Can’t select database".
Any Idea why this is?
I already have a local wordpress site that started saying error connecting to database. The config settings are all correct so i tried to download a fresh wordpress site and use it and I cannot even set up a fresh one. I have never encountered a fresh wordpress site not working like this before.
I did a msqldump of my old site so that my boss could put it on his server. Not sure if that is relevant.
Cheers.
Please don't overcomplicate.
In the "Database Host" field add "localhost: e.g. in my case "localhost:3308" solved the problem.
For anyone who's still looking for solutions to this problem - please, check again your wp-config.php database credentials again. I had the same problem today and tried to over-complicate the matter by searching for advanced solutions, while I had a space in my DB_NAME field (was supposed to be 'wpdb' and was ' wpdb').
This space completely messed up my connection, I was even close to reinstalling the whole thing and losing all data.
If using LAMP -
Make sure that all privileges are granted for that database to the created mysql user. Under your MYSQL shell use the below
GRANT ALL PRIVILEGES ON database_name.* TO database_user#localhost IDENTIFIED BY 'user_password';
Where,
database_name = your database name as per wp-config.php
database_user = your user name as per wp-config.php
userpassword = your user password as per wp-config.php
It sounds like either you have not created a database or your wp-config file is not set up correctly. Have you edited wp-config.php file of wordpress and provided correct database name and user credentials. See Famous 5 minute installation of wordpress for details.
It took me way too long to discover that my msql databases were not working on any other websites either. I reinstalled Wamp Server and it worked.
Verify the wp-config.php file.
I had the same error and the problem was related with the quotes:
‘root’ vs 'root'
edit: the correct one is single quote
'
By default
username : root
password : leave it blank
database host : localhost
table_prefix : wp_
For me, the solution was giving wp_user all permissions on the wp_db database.
I achieved this using the command line interpreter (CLI):
$ mysql -uroot -p
MariaDB [(none)]> GRANT ALL ON `wp_db`.* TO `wp_user`#`localhost` IDENTIFIED BY 'pass';
MariaDB [(none)]> exit;
After these operations, I restarted the database:
$ systemctl restart mysql
Of course, the database name (wp_db), username (wp_user), and password of the user (pass) can be different.
my problem was that when I granted permissions to the DB user the host did not match what was in the wp_config.php
/** MySQL hostname */
define('DB_HOST', 'localhost:3306');
I was granting rights with
GRANT ALL ON databaseName.* TO 'UserName'#'127.0.0.1';
This gave me access when I was connected to the local host through ssh but It did not match wp_config.php. so I had to Grant like this then it all worked.
GRANT ALL ON databaseName.* TO 'UserName'#'localhost';
For Mariadb hostname should be localhost:3306 and for MySQL localhost:3308.this fixed my error.
I had this issue when trying to transfer databases between WAMP server installations.
I tried opening PhpMyAdmin on new PC, then got the port of MySql server (:3308) and added this port into DB_HOST ('localhost:3308'). This worked for me.
please create your database with name 'wordpress' before installing wordpress
You may need to create the database yourself.
Visit http://localhost:8888/phpMyAdmin5
create a new database with the name you prefer.
Don't add any table names, just use the name you choose for the database in the WordPress setup

OpenERP 6.1 Database Migration to new VPS through shell

I've been trying to migrate my old openerp server installation to a new VPS so I tried to migrate the database.
I need to do it via shell because of the size of the database and unstable connection.
What I've done is log in server1 and then
su postgres
pg_dump dbname > db.dump
then I transfered the file to the new server and restored it like this
createdb dbname
psql dbname < db.dump
the database itself was restored and I can browse through the tables if I want to but when I try to get in OpenERP the database is not available in the select box where the databases are. If I create new databases by using the openerp interface they appear correctly in the select box and I can connect.
I tried to create the db with UTF8 encoding and using template1 as well but nothing was different. I also tried to create the database via the interface, drop the tables and restore the backup but this gives errors after I log in like "product.product relation does not exist".
Any ideas what else I could try? Thanks in advance.
When restoring the database take care to restore it with the correct ownership.
You may want to take a look at this question

I have a 18MB MySQL table backup. How can I restore such a large SQL file?

I use a Wordpress plugin called 'Shopp'. It stores product images in the database rather than the filesystem as standard, I didn't think anything of this until now.
I have to move server, and so I made a backup, but restoring the backup is proving a horrible task. I need to restore one table called wp_shopp_assets which is 18MB.
Any advice is hugely appreciated.
Thanks,
Henry.
For large operations like this it is better to go to command line. phpMyAdmin gets tricky when lots of data is involved because there are all sorts of timeouts in PHP that can trip it up.
If you can SSH into both servers, then you can do a sequence like the following:
Log in to server1 (your current server) and dump the table to a file using "mysqldump" --- mysqldump --add-drop-table -uSQLUSER -pPASSWORD -h
SQLSERVERDOMAIN DBNAME TABLENAME > BACKUPFILE
Do a secure copy of that file from server1 to server2 using "scp" ---
scp BACKUPFILE USER#SERVER2DOMAIN:FOLDERNAME
Log out of server 1
Log into server 2 (your new server) and import that file into the new DB using "mysql" --- mysql -uSQLUSER -pPASSWORD DBNAME < BACKUPFILE
You will need to replace the UPPERCASE text with your own info. Just ask in the comments if you don't know where to find any of these.
It is worthwhile getting to know some of these command line tricks if you will be doing this sort of admin from time to time.
try HeidiSQL http://www.heidisql.com/
connect to your server and choose the database
go to menu "import > Load sql file" or simply paste the sql file into the sql tab
execute sql (F9)
HeidiSQL is an easy-to-use interface
and a "working-horse" for
web-developers using the popular
MySQL-Database. It allows you to
manage and browse your databases and
tables from an intuitive Windows®
interface.
EDIT: Just to clarify. This is a desktop application, you will connect to your database server remotely. You won't be limited to php script max runtime, or upload size limit.
use bigdupm.
create a folder on your server witch is not easy to guess like "BigDump_D09ssS" or w.e
Download the http://www.ozerov.de/bigdump.php importer file and add them to that directory after reading the instructions and filling out your config information.
FTP The .SQL File to that folder along side the bigdump script and go to your browser and navigate to that folder.
Selecting the file you uploaded will start importing the SQL is split chunks and would be a much faster method!
Or if this is an issue i reccomend the other comment about SSH And mysql -u -p -n -f method!
Even though this is an old post I would like to add that it is recommended to not use database-storage for images when you have more than like 10 product(image)s.
Instead of exporting and importing such a huge file it would be better to transfer the Shopp installation to file-storage for images before transferring.
You can use this free plug-in to help you. Always backup your files and database before performing this action.
What I do is open the file in a code editor, copy and paste into a SQL window within phpmyadmin. Sounds silly, but I swear by it via large files.

Resources