From 9081ee01151d09dffe4eb92d16d0e0ba1c15b2ac Mon Sep 17 00:00:00 2001 From: Bas Date: Thu, 19 Feb 2015 20:27:23 +0000 Subject: [PATCH 1/2] updated mysql page --- src/persistence/setting_up_mysql.md | 90 +++++++++++++++++++++++++++-- 1 file changed, 85 insertions(+), 5 deletions(-) diff --git a/src/persistence/setting_up_mysql.md b/src/persistence/setting_up_mysql.md index 856ba91..c604c54 100644 --- a/src/persistence/setting_up_mysql.md +++ b/src/persistence/setting_up_mysql.md @@ -26,7 +26,7 @@ $ mysql-ctl stop $ mysql-ctl cli ``` -You can then connect to the database with following parameters: +After having started (and with that created) the database, you can connect to it using the following parameters:
@@ -40,7 +40,7 @@ You can then connect to the database with following parameters: - + @@ -50,12 +50,12 @@ You can then connect to the database with following parameters: - + - - + + @@ -80,6 +80,86 @@ You are now in the MySQL environment and can start the import: To verify that everything got imported run: mysql> show tables; + +Some useful CLI commands (please note the semicolon at the end of most of them): +
+
`Hostname` `$IP`The same local IP as the application you run on Cloud9The environment variable 'IP' (type in a terminal: echo $IP)
`Port`
`User` `$C9_USER`Your Cloud9 user nameYour Cloud9 user name (again an environment variable)
`Password`-No password since you can only access the DB from within the workspace``No password (empty string); access is restricted to the the workspace
`Database`
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Command + Description +
`help``list all mysql commands`
`show databases;``list the available databases`
`use c9``select/use database c9`
`show tables;``list the tables of the current database`
`exit``close the mysql command line tool`
`select * from mysql.user;``show all records/columns from system table user`
+
+ +## Connecting from PHP + +So now you know how to create a database, start the db server, access it via a +command line tool.. It is time for the real deal: accessing it from your code. + +In this example we will connect from PHP: + +1. Create a new file, call it `connect.php` + +2. Copy/paste the following code in there: +```bash +connect_error) { + die("Connection failed: " . $db->connect_error); + } + echo "Connected successfully (".$db->host_info.")"; +?> +``` + +3. Run the code by a right-click on the file tab 'connect.php', select 'run this file' + +4. The output pane shows 'Starting Apache httpd...' + +5. Click the link that is displayed after that + +6. A preview pane will open, showing 'Connected successfully'. + Note: MySQL socket file can be found in ~/lib/mysql/socket/mysql.sock From 465737702fa2f0c876f8e687ca72ae05299e51a6 Mon Sep 17 00:00:00 2001 From: Bas Date: Thu, 19 Feb 2015 21:54:50 +0000 Subject: [PATCH 2/2] small improvements / typo fixes --- src/frameworks/frameworks_wordpress.md | 6 +++--- src/persistence/setting_up_mysql.md | 4 ++-- src/running_and_debugging/common_errors.md | 2 +- src/running_and_debugging/running_wordpress_on_cloud9.md | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/frameworks/frameworks_wordpress.md b/src/frameworks/frameworks_wordpress.md index 18cafae..3b862bc 100644 --- a/src/frameworks/frameworks_wordpress.md +++ b/src/frameworks/frameworks_wordpress.md @@ -1,9 +1,9 @@ -# Getting Started with Wordpress +# Getting Started with WordPress -Wordpress was made to be simple and Wordpress on Cloud9 is no different. Here are some key docs to getting started with Wordpress. +WordPress was made to be simple and WordPress on Cloud9 is no different. Here are some key docs to getting started with WordPress. ### Run & preview your WordPress site -- [Running WordPress sites](https://docs.c9.io/running_wordpress_on_cloud9.html) +- [Running WordPress sites](https://docs.c9.io/running_WordPress_on_cloud9.html) - [Preview your site](https://docs.c9.io/run_an_application.html#pre-view-your-application) ### Build & access your database diff --git a/src/persistence/setting_up_mysql.md b/src/persistence/setting_up_mysql.md index c604c54..697bcbc 100644 --- a/src/persistence/setting_up_mysql.md +++ b/src/persistence/setting_up_mysql.md @@ -128,7 +128,7 @@ In this example we will connect from PHP: 1. Create a new file, call it `connect.php` -2. Copy/paste the following code in there: +2. Copy/paste the following code in there and save the file: ```bash