I am trying to access my ClearDB MySQL database on Heroku via mysql
.
I am using Cloud9 to access Heroku and push my code. I have set up a ClearDB MySQL Ignite as per Heroku's "getting started" guide. The app I am trying to run had some scripts to set up the databases and I have run them through Heroku's bash and the database is been created and I can see that they are working when I visit my app, but some how I cant get the mysql
prompt from Heroku's bash prompt.
I am using this guide to access the mysql prompt How to use Mysql commands with ClearDB in Heroku?
I am getting a the following error:
bash: mysql: command not found
How can I fix this?
mysql
working on Heroku's shell?Heroku dynos contain your application slug and little else. They're more like Docker containers than traditional servers. If you want to use something in your application, including via one-off dynos like the one you get via heroku run bash
, you need to make sure it's included in your slug.
The mysql
command-line client won't be available by default.
mysql
to my slug?I wouldn't recommend it.
Think of your slug as a package for running your application, not a full server. Include what you need to run your application (like a database library for whatever language you're using) and leave extraneous things out.
It's worth noting that there is a maximum size for slugs.
Instead of running mysql
on Heroku, try running it from your Cloud9 terminal. As long as you use the right parameters for your host, user, password, and port as described in the post you linked to it should connect to your ClearDB database.
The test workspace I set up to try this out already had mysql
installed. In case yours doesn't you should be able to install it. My workspace is based on Ubuntu 14.04:
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.5 LTS"
On that OS it should be possible to install mysql
by running
sudo apt-get install mysql-client-5.5