Tag Archives: phpmyadmin

[HOWTO] Setup MySQL, Apache and PHP in Fedora 15

This is a simple guide to setup LAMP (Linux, Apache, MySQL and PHP). I am assuming you have Linux (Fedora 15) installed. The following commands will install the necessary packages to run Apache, MySQL and PHP.

su #for root login, enter password when prompted
yum install mysql-server
service mysqld start
mysqladmin -u root password PASSWORD_HERE
yum install phpmyadmin

Now, you should have necessary packages installed.
To run the apache and mysql services, enter the following in command prompt. This should be done each time you need to use unless you want those services to start with your OS.

su #for root login, enter password when prompted
service mysqld restart
service httpd restart

The directory where you can put in your files is /var/www/html/ and you can access phpMyAdmin by navigating to http://localhost/phpmyadmin

If you want the services to start with your OS, you will need to run the following:

su #for root login, enter password when prompted
chkconfig --add httpd
chkconfig httpd on
chkconfig --add mysqld
chkconfig mysqld on

Hope this helps.

[HOWTO] Install phpMyAdmin in CentOS 5

I am using CentOS 5 in one of my Virtual Servers and I wanted it to have phpMyAdmin. I tried installing it by doing yum install phpmyadmin but it said No package phpmyadmin available. So I add to add a repo. I discovered that rpmforge repo had this package. To add it, I executed the following commands:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.i386.rpm

If you have 64-bit version installed, you should try this one out:

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm

If you get a 404 Not Found, then you will need to figure out the latest updated version of repo url from rpmforge usage page.

After that, you may like to update your packages by doing this:

yum update

and then continue installing phpmyadmin

yum install phpmyadmin

It should ask you for confirmation and you can continue installing phpMyAdmin with dependencies.

When installation is done, you can edit /etc/httpd/conf.d/phpmyadmin.conf and allow it to be opened from anywhere and not just the same computer. You are going to need this if you have installed it in a remote virtual server.
To do so, open up /etc/httpd/conf.d/phpmyadmin.conf using:

nano /etc/httpd/conf.d/phpmyadmin.conf

You will see:


  Order Deny,Allow
  Deny from all
  Allow from 127.0.0.1

Just change the line “Allow from 127.0.0.1” to “Allow from [yourip]”, where [yourip] is IP address of your computer if you have public static IP. Otherwise, you can also set it to “Allow from all”.
Press Ctrl+O followed by Enter to save and Ctrl+X to exit nano.

Now, you must restart apache. To do so, run

service httpd restart

Now, you can access phpMyAdmin by visiting http://vps_server_IP_or_domain/phpmyadmin. But you will get the following error:

Error
The configuration file now needs a secret passphrase (blowfish_secret).

To make it work, you will need to edit config.inc.php. To do so, type in:

nano /usr/share/phpmyadmin/config.inc.php

Find a line saying:

$cfg['blowfish_secret'] = ''; /* YOU MUST FILL IN THIS
FOR
COOKIE AUTH! */

Fill in any secret keyword there, eg mysecretpassphrase, so that it looks like:

$cfg['blowfish_secret'] = 'mysecretpassphrase'; /* YOU MUST FILL IN THIS
FOR
COOKIE AUTH! */

and then save it.

If you don’t have mysql server installed, you will get the following error:

Error
#2002 – The server is not responding (or the local MySQL server’s socket is not correctly configured)

To install mysql-server, just run:

 yum install mysql-server

and then start it:

 service mysqld start

Then change the root password:

mysqladmin -u root password PASSWORD_HERE

Now, you will have to remove phpmyadmin:

yum remove phpmyadmin

and reinstall it again:

yum install phpmyadmin

Then you will need to edit the config.inc.php again to enter blowfish secret (see above). Then, you can login.

If however, you want phpMyAdmin to connect to a remote server, you can change the line by replacing localhost with your server IP:

$cfg['Servers'][$i]['host'] = 'localhost';

Hope this helps.

[HOWTO] Configure remote connection to MySQL database server

I recently got a Ubuntu 8.04 Dedicated Server and wanted to move the database of one of my websites from my web host to the Dedicated Server while keeping the website in the web host. To do so, you must make sure you can connect to remote databases from your web host to the Dedicated Server (or VPS).

First, I exported the database from my web server into a .sql.gz file. You can choose .sql too. Then, I created a database (lets call it newdb) in the remote server using phpmyadmin (if you don’t have phpmyadmin, you can install it in your dedicated server) and imported the database.

Now we move on to the remote privilege part. Login to your Dedicated Server via ssh. We will need to edit my.cnf (the MySQL configuration file) to make the mysql server bind to the IP of the Dedicated Server, not localhost or 127.0.0.1. We do that by typing in:

nano /etc/mysql/my.cnf

I use nano as my text editor, you may use vi or whatever text editor you want. Also, my.cnf is in /etc/mysql/my.cnf, yours might be /etc/my.cnf.
Now, scroll down until your find

[mysqld]

Just a few lines below, you will find a line containing:

bind-address            = 

That line may be commented (with a # in the beginning) or may have localhost or 127.0.0.1 as bind-address. We do not want that. We want the IP of our dedicated server. Lets say it is 67.67.67.67, so the new line should look like:

bind-address            =  67.67.67.67

Save the file. If using nano, just press Ctrl+O and Enter. Press Ctrl+X to exit. If using vi, press Esc and type :w to save and :q to quit.
Restart the mysql server by using the following command.

/etc/init.d/mysql restart

Now, fire up mysql:

mysql -u username -p

Enter password when asked. The username must be of an administrative user.
Now, lets switch to the database we created earlier with phpmyadmin:

use newdb

That should say:

Database changed

Now, we create a new user and allow it to connect to the database:

grant CREATE,INSERT,DELETE,UPDATE,SELECT on newdb.* to newuser@66.66.66.66;

where 66.66.66.66 is the IP of the web host. It can be found by pinging your domain. For example, if you have domain mydomain.com, you can simply do a:

ping mydomain.com

and find out the IP in terminal. It should give you something lie:

PING mydomain.com (66.66.66.66) 56(84) bytes of data.

Now, we set password for the user newuser. We do that by typing in:

set password for newuser@66.66.66.66 = password('mypassword');

Finally, we cleanup and exit mysql:

flush privileges;
exit;

Now, we are done. You can configure the website in the web host to connect to the database at your remote Dedicated Server with the following configuration (whatever applies to you):
database=newdb
username=newuser
host=67.67.67.67

References:
http://www.debian-administration.org/article/Adding_new_users_to_MySQL_Databases
http://www.debianhelp.co.uk/remotemysql.htm