login community faq

I'd like to install MySQL into my home directory so that I have full "root access" to my databases; also my application requires a newer version of MySQL than the shared instance already provided for use.

I tried following the instructions on this forum post but I get the error:

-bash: ./configure: No such file or directory

So, I think the instructions are out-of-date. Is there a newer procedure for installing MySQL on WebFaction?

asked May 27 '11 at 04:53

ryans's gravatar image

ryans ♦♦
1941110

edited May 27 '11 at 19:15


Yes. For anyone who is interested in building and maintaining their own private MySQL instance, the compilation procedure has changed compared to the old forum post regarding this topic. The new procedure follows.

In order to compile and install a private MySQL instance, you should first create a new Custom Application (listening on port) in the Control Panel. This will reserve a port for your new database server, which your applications will connect to.

Note: we are not using the Custom Application to serve the MySQL instance; it's merely reserving the port. Therefore, you should not attach the application to a website record. If you require remote access to your database, please open a support ticket to ask us to open your MySQL database port in the firewall.

Once the Custom Application (listening on port) has been created, the Control Panel will assign you a port for it. Use that port in the MY_PORT variable below.

Next, you can compile the MySQL instance into ~/mysql using the following commands. This will also install cmake into your ~/bin directory. It is required to build MySQL and you may need it in the future to build other software as well.

#### Begin MySQL Build Commands ####

MY_PORT=47389

mkdir -p ~/mysql/.src
cd ~/mysql/.src
wget http://www.cmake.org/files/v2.8/cmake-2.8.4.tar.gz
tar -xzf cmake-2.8.4.tar.gz
cd cmake-2.8.4
./configure --prefix=$HOME
make
make install

mkdir -p ~/mysql/.src ~/mysql/tmp
cd ~/mysql/.src/
# Download and extract the Mysql source code:
wget 'http://downloads.mysql.com/archives/mysql-5.5/mysql-5.5.12.tar.gz'  # md5 53d31a0b24f3eb3176185090eff129b9
tar -xzf mysql-5.5.12.tar.gz
cd mysql-5.5.12
cmake -DCMAKE_INSTALL_PREFIX=$HOME/mysql -DMYSQL_TCP_PORT=$MY_PORT -DWITH_INNOBASE_STORAGE_ENGINE=1 .
make
make install

#### End MySQL Build Commands ####

Next, you will need to create the database. This can be done with something like the following commands, substituting your desired password:

#### Begin MySQL Post-Install Setup ####

echo export PATH=$HOME/mysql/bin:$HOME/mysql/scripts:$PATH >> ~/.bash_profile
source ~/.bash_profile

mysql_install_db --basedir=$HOME/mysql --datadir=$HOME/mysql/data --tmpdir=$HOME/mysql/tmp --user=$USER

# create a my.cnf file
cp $HOME/mysql/support-files/my-small.cnf $HOME/mysql/my.cnf

# Start the MySQL Server:
cd $HOME/mysql; mysqld_safe --defaults-file=$HOME/mysql/my.cnf --socket=$HOME/mysql/mysql.sock &

# Choose a password for root:
mysqladmin -u root -P $MY_PORT -S $HOME/mysql/mysql.sock password "aPasswordForRoot"

#### End MySQL Post-Install Setup ####

Next, you can test the server by connecting to it:

mysql -P $MY_PORT -S $HOME/mysql/mysql.sock -u root -p

Finally, you'll need to configure your applications to use the new database server. Specifically, you will need to configure your applications to use the following settings:

  • Database host: localhost or 127.0.0.1
  • Database port: the port assigned to your custom MySQL app in the control panel
  • Database name: the name of the database that you want to use (this must be a database that you created in your custom MySQL, not a database that you created in our control panel)
  • Database user: the user for the database that you want to use (this must be a user that you created in your custom MySQL, not a database that you created in our control panel)
  • Database password: the password assigned to your database user.

Hope that helps!

This answer is marked "community wiki".

answered May 27 '11 at 19:14

ryans's gravatar image

ryans ♦♦
1941110

edited May 03 at 21:31

Thanks ! Everything worked fine for me with mysql 5.5.14. Very good post ;)

But now, how can I update the PHP MySQL Client (5.0.77) ?

With a new Apache/PHP stack ??! With this script : https://gist.github.com/924019 for example ?

What happens when the server goes down ? How can I configure autostart ?

(Aug 27 '11 at 09:02) BenLeTib BenLeTib's gravatar image

But now, how can I update the PHP MySQL Client (5.0.77) ?

With a new Apache/PHP stack ??! With this script : https://gist.github.com/924019 for example ?

Yes, if you need a newer version of the PHP MySQL client, then you'll need to build your own PHP stack from source.

What happens when the server goes down ? How can I configure autostart ?

You could use Supervisor to monitor your MySQL processes and restart them if they go away. Supervisor could watch your custom Apache instance also. We don't have a step-by-step tutorial for setting that up though.

Another approach would be to run a simple cron job every minute that attempts to connect to your MySQL server instance and restart it if it fails.

(Aug 27 '11 at 10:59) seanf ♦♦ seanf's gravatar image

Hello, I have followed your instructions and everything seems to have gone alright except one thing: in order to connect to the database I have to specify the location of the socket file

if I write:
mysql -P $MYPORT -u root -p -S $HOME/mysql/mysql.sock
it connects without problem,

but if I omit the socket option, I receive this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

so it seems that the default location of the socket file is inside the tmp directory. I could copy the file there, but I fear that it will be deleted while cleaning the tmp directory, so: how can I change the default location of the socket configuration file?

I think it is necessary because I do not know if the socket option can be passed by PHP connection string
Thanks

EDIT: I managed to locate the socket in my tmp directory but still get the error message when connecting without indicating the socket location relative to my home directory. It seems that by default it looks in to the main tmp directory relative to the server root and not the local one.

(Mar 26 at 09:52) robertotra robertotra's gravatar image
1

You can specify a different socket in PHP by defining mysql.default_socket in a php.ini file in the root of your app directory.

(Mar 26 at 12:40) seanf ♦♦ seanf's gravatar image

This is great. I forgot it was possible on WF to override the php.ini directives. Thank you very much !!

(Mar 26 at 14:27) robertotra robertotra's gravatar image

Just a curiosity: in case one wants to upgrade in the future his/her custom installation to a next version of mysql (and considering that a backup of existing data is anyway advisable before proceeding) what do you suggest as better:

a) upgrade the existing server
b) install a new server and then migrate data

Thanks

(Mar 29 at 02:07) robertotra robertotra's gravatar image

Install the new server and than migrate data, its safer.

(Mar 29 at 02:38) johns ♦♦ johns's gravatar image
showing 5 of 7 show all
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×75

Asked: May 27 '11 at 04:53

Seen: 1,040 times

Last updated: May 03 at 21:31

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited