Category Archives: MySQL

Increase the phpMyAdmin session timeout

Edit your config.inc.php file (in my Ubuntu 12.04 it was located at /etc/phpmyadmin/config.inc.php) and add the following line (where X is the amount of seconds the session will last):

$cfg['LoginCookieValidity'] = X;

phpmyadmin-login

In my development machine I have 36000 that is 10 hours (all work day) but you should never do this in a production environment.

You may also have to set the same value on session.gc_maxlifetime in your php.ini file because it will probably be smaller than LoginCookieValidity value you set before (it’s default value is 1440).

session.gc_maxlifetime = 36000

Ref: http://venutip.com/content/increase-phpmyadmin-session-timeout

Useful Apache 2 and MySQL 5 service aliases for MacPorts

Those are some aliases I use to start, stop and restart Apache 2 and MySQL on my MacPorts installation done with the installation script I made some time ago. You have to edit “~/.bash_profile” file and add those lines:

alias mysql5start='sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start'
alias mysql5stop='sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop'
alias mysql5restart='sudo /opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper restart'

alias apache2start='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start'
alias apache2stop='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop'
alias apache2restart='sudo /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart'

Then execute “source ~/.bash_profile” to load the new aliases or just open a new terminal window.

Change root password in MySQL

In GNU/Linux:

$ sudo mysqld_safe --skip-grant-tables &
$ mysql -u root -p
#press enter to use a blank password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;
$ sudo service mysql stop
$ sudo service mysql start
#try your new password
$ mysql -u root -p

In Mac OS X with MySQL installed with MacPorts:

$ sudo /opt/local/lib/mysql5/bin/mysqld_safe --skip-grant-tables &
$ mysql -u root -p
#press enter to use a blank password
mysql> use mysql;
mysql> update user set password=PASSWORD("NEW-ROOT-PASSWORD") where User='root';
mysql> flush privileges;
mysql> quit;
$ sudo port unload mysql5
$ sudo port load mysql5
#try your new password
$ mysql -u root -p

Run shell commands in Mac OS X executing a normal application

Once I installed Apache2+MySQL5+PHP5.3 using MacPorts I wanted to start and stop the services without having to open a terminal window a run the commands myself. This can be achieved creating an AppleScript that executes the command and then saving it as an application.

Open the AppleScript editor (Utilities→AppleScript Editor.app) and write the command you want to run. I had to create 4 different applications because I wanted the start and stop applications for both Apache2 and MySQL5. As the commands must be run as an administrator I added at the end “with administrator privileges” (the application will ask for the password):

do shell script "/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper start" with administrator privileges
do shell script "/opt/local/etc/LaunchDaemons/org.macports.mysql5/mysql5.wrapper stop" with administrator privileges

It’s VERY IMPORTANT to clic the “Compile” button to be sure everything is correct and that the application is created. Now you only have to go to “File→Save…” and save it with the “Application” format.

Apache 2 + MySQL 5 + PHP 5.3 + phpMyAdmin 3.5.4 installation script for Mac OS X using MacPorts

Based on the instructions provided by Gilles Fabio I’ve created a complete installation script to install Apache 2, MySQL 5, PHP 5.3 and phpMyAdmin 3.5.4 for Mac OS X using MacPorts.

It’s important to know that as MacPorts compiles all the ports from source you have to have installed “Command Line Tools” (download it from http://connect.apple.com/, an Apple ID is needed) and once installed run xcodebuild -license from the command line to accept the EULA.

It automatically installs and configures everything you need to have a working Apache+MySQL+PHP environment. Once installed the most important files can be located here:

httpd.conf:         /opt/local/apache2/conf/httpd.conf
httpd-vhosts.conf:  /opt/local/apache2/conf/extra/httpd-vhosts.conf
htdocs folder:      /opt/local/apache2/htdocs
php.ini:            /opt/local/etc/php5/php.ini
config.inc.php:     /opt/local/apache2/htdocs/phpmyadmin/config.inc.php
my.cnf:             /opt/local/my.cnf
mysqld.sock:        /opt/local/var/run/mysql5/mysqld.sock

You can download it from my Github repository: installMacPorts-Apache-MySQL-PHP-phpMyAdmin-OSX.sh

Look at my article about how to configure the virtual hosts so you can have multiple websites in the same server.

UPDATE: You can install PHP 5.4 using this guide: https://gist.github.com/2721719

  • Page 1 of 2
  • 1
  • 2
  • >