Guide On How To Install phpMyAdmin On FreeBSD

Guide On How To Install phpMyAdmin On FreeBSD 2017-08-23T12:22:08+00:00

A Step By Step Guide On How To Install phpMyAdmin On FreeBSD
phpMyAdmin is a web interface for administrating MySQL. Mostly for the people out there who neither have the time or
interest in learning how to administrate MySQL from command line. Installing phpMyAdmin on FreeBSD is really quite easy.

cd /usr/ports/databases/phpmyadmin && make install clean BATCH=yes

Now while it is possible to set all of this up and then access phpmyadmin with a root account I strongly advise against it. Instead create a superuser account for this purpose. This can be done like this. Replace “username” and “password” with the real username and password you would like to use.

mysql -u root -p
connect mysql
CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';

In order for phpMyAdmin to stop complaining about not having a phpmyadmin database let’s create one and import the tables for it.

mysql -u root -p
connect mysql
create database phpmyadmin;
GRANT ALL PRIVILEGES ON phpmyadmin TO 'username'@'localhost';
GRANT ALL PRIVILEGES ON phpmyadmin.* TO 'username'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;

Next we need to import the phpmyadmin tables. When prompted enter the username for the phpmyadmin user you created earlier.

cd /usr/local/www/phpMyAdmin/sql
mysql -u username -p phpmyadmin < create_tables.sql 

Now we need to create a configuration file for phpMyAdmin.

cd /usr/local/www/phpMyAdmin
cp config.sample.inc.php config.inc.php

Once done we need to edit a few things to get this working.

cd /usr/local/www/phpMyAdmin
cp config.sample.inc.php config.inc.php

Find the highlighted line.

/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = ' '; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**

And add some random characters between the two ticks ' ' at least 32 characters long. So it ends up looking something like this.

/**
 * This is needed for cookie based authentication to encrypt password in
 * cookie. Needs to be 32 chars long.
 */
$cfg['blowfish_secret'] = 'w5QL3NFMYu7XKTUZFnMUsXaujaSWgGEx'; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
/**

Next find these 2 lines.

// $cfg['Servers'][$i]['controluser'] = 'pma';
// $cfg['Servers'][$i]['controlpass'] = 'pmapass';

Remove the two // on both lines and change "pma" to the "username" for phpmyadmin you created earlier and change "pmapass" to the password you added to that username. So it ends up something like this.

$cfg['Servers'][$i]['controluser'] = 'username';
$cfg['Servers'][$i]['controlpass'] = 'password';

Finally let's adjust the apache configuration file so we can access phpMyAdmin. While we are add it let's ad a bit of security as well. Replace IP-address with the IP-Address allowed to access phpMyAdmin for more IP-Addresses simply add them on the same line using "space" as a delimiter.

Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"

    Options None
    AllowOverride Limit
    Require all denied
    Require ip IP-Address
 

Restart apache for the changes to take effect. And you should now be able to access phpMyAdmin from your browser. You are greeted first by the login screen [screenshot] and if everything works you will end up at the phpMyAdmin main screen [screenshot].

And we are done here.

Spell checkers don’t – Grammar checkers don’t either.