Rizwan
Rizwan

Reputation: 1

importing database to openshift

hi guys i still could not import my .sql file as well as connect my database to my openshift application.would appreciate step by step guide on how to do so.These are my gears

php-5.3 (PHP 5.3)


Gears: Located with mysql-5.5

mysql-5.5 (MySQL 5.5)


Gears:          Located with php-5.3
Connection URL: mysql://$OPENSHIFT_MYSQL_DB_HOST:$OPENSHIFT_MYSQL_DB_PORT/
Database Name:  myapp
Password:       *******
Username:       *******

This is my php script for my mysqli_connect

    DEFINE ('DB_USER', '******');
    DEFINE ('DB_PASS', '******');
    DEFINE ('DB_HOST',  '127.12.136.130');
    DEFINE ('DB_NAME', 'myapp');


    // Make the connection:
    $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to        MySQL: ' . mysqli_connect_error() );

    // Set the encoding...
    mysqli_set_charset($dbc, 'utf8');

I already have my directory for my .sql file C:\Users\User>C:\Users\User\Desktop\mysqlmyapp.sql

I'm using microsoft webmatrix which runs on localhost but i need my database to be on my openshift server

Upvotes: 0

Views: 1350

Answers (2)

Comfort Chauke
Comfort Chauke

Reputation: 126

if your file are LARGE [like mine] phpmyadmin will harass you. However, you can scp the file to remote.

rhc scp awesomeapp upload ./largeSql.sql /tmp/

then

rhc ssh -a awesomeapp

and once inside run

mysql -u "$OPENSHIFT_DB_USERNAME" --password="$OPENSHIFT_DB_PASSWORD" -h "$OPENSHIFT_DB_HOST" -P "$OPENSHIFT_DB_PORT" [DBNAME] < MySQL.sql

at this stage you could use phpmyadmin but i haven't tried it

Upvotes: 1

Wissam El-Kik
Wissam El-Kik

Reputation: 2525

If you're using Red Hat OpenShift, you simply need to add 2 cartridges:

  • MySQL
  • PHPMyAdmin

1- Login to OpenShift

2- Select your application

3- Click on the following button to add a new cartridge: Browse the Marketplace, or see the list of cartridges you can add

4- Add the "MySQL" and the "PHPMyAdmin" cartridges

5- Go to the console again, then select the application and then click on the PHPMyAdmin link

6- There's a tab in PHPMyAdmin called "Import"

7- Here you can upload your SQL file

If you're file is less than 4MB, you won't encounter any problem.

Upvotes: 1

Related Questions