0

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

Bhumi Shah
  • 9,323
  • 7
  • 63
  • 104
Rizwan
  • 1
  • 1

2 Answers2

1

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.

Wissam El-Kik
  • 2,469
  • 1
  • 17
  • 21
  • In case your SQL file is bigger than 4MB, then you might consider the solutions written here: http://stackoverflow.com/questions/5051253/phpmyadmin-cant-import-huge-database-file-any-suggestions Also, if you don't have access to the Server settings, which is most probably the case in OpenShift, then you might go the ol' way copy-pasting parts of the SQL file manually ... good luck :P – Wissam El-Kik Sep 29 '14 at 14:07
  • Can i also ssh into MySQL and just paste in my directory to my sql.file? – Rizwan Sep 30 '14 at 03:00
  • Yep, you can use SSH and if you can put the file there on the server using Git, you'll have to use the following command: `mysql -u username -p database_name < file.sql` to import the SQL file. – Wissam El-Kik Sep 30 '14 at 07:28
1

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

Comfort Chauke
  • 126
  • 1
  • 9