Lubuntu cont’d – add MySQL & phpMyAdmin

I’m following the directions on the page called ApacheMySQLPHP in the section called Installing MYSQL with PHP 5.

Why I Copy other People’s Writings

Install MySQL

Use any method to install

mysql-server
libapache2-mod-auth-mysql
php5-mysql

Password for “root” MySQL User

During the command line install of mysql-server I was asked to create this password. The P/W is the same as my laptop’s.

U/N: root
P/W: the same as my laptop’s
D/B: all databases

It’s best not to change the root password which I just set because it’s complicated to do it on the command line; and it can really get things screwed up!

memory_limit in php.ini

The UBUNTU instructions say:

You may need to increase the memory limit that PHP imposes on a script. Edit the /etc/php5/apache2/php.ini file and increase the memory_limit value.

This is not necessary because the current version of php5 has 128M as the current php.ini setting for memory_limit. Which is enough!

Set mysql bind address

Before you can access the database from other computers in your network, you have to change its bind address. Note that this can be a security problem, because your database can be accessed by other computers than your own. Skip this step if the applications which require mysql are running on the same machine.

So, I skipped it!

Configuration File

/etc/mysql/my.cnf

Create a mysql database

mysql -u root -p
mysql> CREATE DATABASE samehrlabib_aTestMyLAMP;

Now there is a database called:

samehrlabib_aTestMyLAMP;

To exit the mysql client:

mysql> \q

Every mysql command must end with a ; or \g . A \q is for exiting the mysql CLI.

Create a mysql user

For creating a new user with all privileges (use only for troubleshooting), at mysql prompt type:

mysql> GRANT ALL PRIVILEGES ON *.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword' WITH GRANT OPTION;

For creating a new user with fewer privileges (should work for most web applications) which can only use the database named database1, at mysql prompt type:

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON database1.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword';

yourusername and yourpassword can be anything you like. database1 is the name of the database the user gets access to. localhost is the location which gets access to your database. You can change it to '%' (or to hostnames or ip addresses) to allow connections from every location (or only from specific locations) to the database. Note, that this can be a security problem and should only be used for testing purposes!

When I created the database samehrlabib_aTestMyLAMP I had intended it to be used by a user named samehrlabib. This user will have fewer privileges than someone like root. Now, I’ll create this mysql user:

mysql> GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, DROP, INDEX, ALTER, CREATE TEMPORARY TABLES, LOCK TABLES ON samehrlabib_aTestMyLAMP.* TO 'samehrlabib'@'localhost' IDENTIFIED BY 'password';

This is not the exact command. Substitute the password. The actual P/W for samehrlabib mysql user is the same as it is on my iMac (etnashar(nemra)_girls(3araby)_esm-kalby-el-tany).

U/N: samehrlabib
P/W: etnashar(nemra)_girls(3araby)_esm-kalby-el-tany
D/B: samehrlabib_aTestMyLAMP

Install phpMyAdmin (PMA)

I thought I wouldn’t have to install PMA because I assumed I’d find the files for the phpMyAdmin scripts in my Dropbox directory—and thereby not have to install anything. But, I didn’t find them in /home/sameh/Dropbox/Sites/.

So, where did I put them when I installed phpMyAdmin on my iMac?

In the web share directory on my iMac.

So, I guess that’s also where these script will end up being placed on my laptop.

But how did PMA end up having the URL http://sameh-labibs-imac.local/phpMyAdmin/ on the iMac?

Mostly, by using Apache2 Alias directive. See post about my iMac install and this one: What a File Path Represents in Apache Configuration. There is a lot more to this if you want to get it right.

Therefore, I’ll need to install PMA.

apt-get install phpmyadmin

This apt-get command installed the following packages:

phpmyadmin
php5-gd
php5-mcrypt
dbconfig-common

also, it modified the Apache configuration— although, for some reason, it didn’t create an Alias directive for the redirection of /phpmyadmin in a URL to the actual directory of the phpmyadmin script in the file system—see my previous remarks. MORE ON THIS BELOW.

dbconfig-common was a terminal GUI which helped prepare the database for phpmyadmin. To accomplish this it created a new database called phpmyadmin; then, it assisted in creating a user for this particular database:

U/N: phpmyadmin
P/W: the same as for my other users on this laptop
D/B: phpmyadmin

This user/database combo allows PMA to maintain its settings.

Never change the password for the mysql user phpmyadmin@localhost unless you are willing to also change it in /etc/dbconfig-common/phpmyadmin.conf .

Two configuration files were created:

/etc/dbconfig-common/phpmyadmin.conf
/etc/phpmyadmin/config-db.php

controluser phpmyadmin@localhost

This user is configured with limited permissions. The user phpmyadmin@localhost is for the use of the advanced phpMyAdmin configuration storage features.

I’ll never have to login to PMA as this user; because, the U/N and P/W are set in a PMA configuration file called config.inc.php.

Apache configuration for phpmyadmin

See How to install and configure Apache,PHP,MySql and phpMyadmin on ubuntu

I placed an Apache configuration file for PMA in the directory /etc/apache2/conf.d . The content for this new configuration file which I created was copied from /etc/phpmyadmin/apache.conf . I named this file phpmyadmin.conf .

So now the active Apache configuration file for PMA is:

/etc/apache2/conf.d/phpmyadmin.conf
Advertisements

About samehramzylabib

See About on https://samehramzylabib.wordpress.com
This entry was posted in Configure My Systems. Bookmark the permalink.

One Response to Lubuntu cont’d – add MySQL & phpMyAdmin

  1. Pingback: Lubuntu cont’d — add PHP | Sam's PHP How-To

Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s