-6

c9.io is a verygood website

I have a php zoon , and when I want to connect to MySQL,I don't know password. I have try [space] root ... but,all is wrong.

I can open mysql in shell , no password ,my operate return error: error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'

It's looks like, mysqld is not started 。(I have try “mysqld start”,but faild)

What I want to know, Is Mysql service free on c9.io ?

Channe
  • 109
  • 1
  • 1
  • 8

2 Answers2

6

We are extremely happy to announce our first iteration of MySQL support in Cloud9. It makes it super easy to install, start and stop a MySQL instance right in your workspace. The nice thing is that every workspace will run a separate database so your projects will never interfere with each other. You can control MySQL with the mysql-ctl command line tool run from the terminal.

# start MySQL. Will create an empty database on first start
$ mysql-ctl start

# stop MySQL
$ mysql-ctl stop

# run the MySQL interactive shell
$ mysql-ctl cli

You can then connect to the database with following parameters:

Option    Value   Comment
Hostname  $IP The same local IP as the application you run on Cloud9
Port  3306    The default MySQL port number
User  $C9_USER    Your Cloud9 user name
Password  -   No password since you can only access the DB from within the workspace
Database  c9  The database name

Of course this is just the beginning. We have for example plans to add a management UI to start and stop databases or pre-installing tools like phpMyAdmin. However we don’t want to make you wait for the fully integrated feature while we already have something that is enabling a lot of use cases and still super easy to use.

Stay tuned and happy coding.

Channe
  • 109
  • 1
  • 1
  • 8
0

The documentation show how start, stop, and run the mysql environment.

Start the MySQL shell mysql-ctl start then in yor file.php:

$ip =  getenv("REMOTE_ADDR");
$port = "3306";
$user = "YorUsername";
$DB = "c9";

$conn = mysql_connect('$ip', '$user', '', '$db', '$port')or die(mysql_error());
mysql_select_db('$db','$conn')or die(mysql_error());
mysql_query("select * from YourTableName",'$conn')or die(mysql_error());

The line getenv("REMOTE_ADDR") return the same local IP as the application you run on Cloud9.