Showing posts with label Database. Show all posts
Showing posts with label Database. Show all posts

Install phpMyAdmin in IIS 5.1

Yosh! Now we're already done setting up PHP 5.3 to IIS 5.1 and MySQL Server 5.0, now this guide is for Installing phpMyAdmin in IIS 5.1 and PHP 5.3. If you need some assistance in setting up PHP in IIS 5.1 or MySQL Server 5.0, do check the following links:
Next is to download the latest version of phpMyAdmin at http://www.phpmyadmin.net/home_page/downloads.php and extract the files to the appropriate directory inside your IIS web root (C:\Inetpub\wwwroot\) so that IIS is able to access it. You may wish to create a separate website for your phpMyAdmin installation, or simply add it as a sub directory or virtual directory under an existing website. Either way you'll need to make sure that the user account used by IIS to access your files has at least NTFS read permissions to all of your files once they are in place.In this guide we'll place the phpMyAdmin files in a directory called "pma" under the root directory of a website "localhost". With all this in mind, then to access the phpMyAdmin installation used in this guide you would type the following into the address bar of your web browser "http://localhost/pma".

PHP Settings

phpMyAdmin uses several PHP extensions to perform its various functions. The extensions you'll need for phpMyAdmin are:
  • MySQL (to connect to the MySQL server)
  • MCrypt (highly recommended for performance when using the cookie authentication method, and actually required for 64-bit environments)
  • MBString (used for multi-byte character support)
  • GD2 (image creation and manipulation library)
To enable these extensions open you php.ini file and navigate to the list of extensions and find these extension names, simply remove the semi-colon (;) from that start, save the file and restart IIS to reload your PHP environment.
;extension=php_gd2.dll
;extension=php_mbstring.dll
;extension=php_mcrypt.dll
;extension=php_mysql.dll
These extensions should now be loaded into your PHP environment, and can be verified using the phpinfo function.

Creating you phpMyAdmin config file

Next  is to create your config file for the phpMyAdmin. To do this the easiest way is to copy the config.sample.inc.php file in you phpMyAdmin root directory and rename it to config.inc.php. Using this sample config file as a base means there are literally only a handful of settings that need to be added or altered so that you have a working configuration. Make sure you add/edit in the following: 
$cfg['blowfish_secret'] = '<typeinanywordinhere>';

/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '<yourMySQLUsername>';
$cfg['Servers'][$i]['password']  = '
<yourMySQLPassword>';

/* Select mysqli if your server has it */
$cfg['Servers'][$i]['AllowNoPassword'] = true;

/* User for advanced features */

$cfg['docSQLDir'] = 'docsql';
$cfg['ShowPhpInfo'] = true;
$cfg['ShowChgPassword'] = true;
$cfg['AllowArbitraryServer'] = false;
$cfg['LoginCookieRecall'] = 'something';
$cfg['LoginCookieValidity'] = 1800;
$cfg['AllowAnywhereRecoding'] = true;
$cfg['DefaultCharset'] = 'iso-8859-1';
$cfg['RecodingEngine'] = 'iconv';
$cfg['IconvExtraParams'] = '//TRANSLIT';
$cfg['GD2Available'] = 'yes';
$cfg['CheckConfigurationPermissions'] = FALSE;
$cfg['Servers'][$i]['hide_db'] = '(information_schema|phpmyadmin|mysql)';

From here you should actually be able to log into your new phpMyAdmin installation by typing http://localhost/pma to your web browser. phpMyAdmin won't be asking for your MySQL Username and Password since you already stored it in $cfg['Servers'][$i]['user'] and $cfg['Servers'][$i]['password'].


Now we need to configure the privileges for the Username you used in accessing MySQL Server 5.0. Open MySQL Command Line Client by clicking Start > All Programs > MySQL > MySQL Command Line Client. Enter your password and type in the following SQL Statements:

GRANT USAGE ON mysql.* TO 'yourMySQLUsername'@'localhost' IDENTIFIED BY 'yourMySQLPassword';
GRANT SELECT (
    Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
    Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
    File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
    Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
    Execute_priv, Repl_slave_priv, Repl_client_priv
    ) ON mysql.user TO 'yourMySQLUsername'@'localhost';
GRANT SELECT ON mysql.db TO 'yourMySQLUsername'@'localhost';
GRANT SELECT ON mysql.host TO 'yourMySQLUsername'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
    ON mysql.tables_priv TO 'yourMySQLUsername'@'localhost';
GRANT SELECT, INSERT, DELETE, UPDATE ON `phpmyadmin`.* TO
   'yourMySQLUsername'@localhost;

What we did was we enabled all access to the Username you used in MySQL Server and hurray! Your phpMyAdmin is now working properly! You may now access phpMyAdmin in http://localhost/pma to your browser with no problems.

If you have any comments, questions about the installation and suggestions please feel free to post here. Thanks again for sticking around! ^_^

Install MySQL Server 5.0 in IIS 5.1 and PHP 5.3


Yay! We're already done setting up PHP 5.3 to IIS 5.1, now this guide is for Installing MySQL Server 5.0 in  IIS 5.1 and PHP 5.3. I'm assuming you have IIS 5.1 already installed in your system and if you still need to setup PHP 5.3 then please check the Installing PHP 5.3 in IIS 5.1 guide. Now for installing MySQL Server 5.1 you will need to download latest stable release version here: http://dev.mysql.com/downloads/mysql/5.1.html. In this tutorial I am going to be using the Windows Essentials (x86) version which has all the core functionality you need to run a MySQL database server. Launch the mysql-essential-5.0.26-win32.msi installer file to start the MySQL Setup Wizard.


Click Next and then choose a custom installation as this will allow us to specify an installation directory of our own choosing. In this example I will be using installing MySQL into the "C:\MySQL" folder.

 

 On the Custom setup dialog box click Change to specify the preferred installation directory.

 


 Select the directory you want to use and then click OK to go back to the Custom setup dialog box.

 

Click next. MySQL is now ready to be installed. Click Install to begin the installation.



At the MySQL.com Sign Up screen click Skip Sign-Up and then click Next.


On the next dialog box ensure that ‘Configure the MySQL Server now’ tick box is checked and click Finish, then this will open the Server Instance Configuration Wizard. Click Next to begin configuring your MySQL server.



Choose Detailed Configuration and click Next.

 

In this example I am installing MySQL on the same machine as my IIS web server so I opt for the Server Machine option. Choose a server type which is appropriate for your requirements and click Next.

 

Choose the type of database which best suits your needs and click Next.

 

Leave the default setting of the MySQL installation path for the InnoDB Tablespace settings (unless you wish to change it) and click Next.


Select the appropriate number of concurrent connections you want to allow and click Next.


Leave the default networking options settings (unless you have reason to change them) and click Next.

 

Choose the appropriate character set for your requirements and click Next.

 

On the Windows options dialog box ensure that both ‘Install As Windows Service’ and ‘Include Bin Directory in Windows Path’ tick boxes are selected and click Next.


In the security options dialog box ensure that ‘Modify Security Settings’ is ticked and type in your new root password. Decide whether or not you wish to allow root access from remote machines or create an anonymous account and click Next.
 

If you are happy with the choices you have made click Execute to begin configuring your server.

Once the Configuration Wizard has finished click Finish to begin using your new MySQL server.
Now that we have got MySQL installed we need to create a test user account which we will use later in this walkthrough to test connectivity to MySQL from a PHP script. Start by opening the MySQL Command Line Client. When prompted enter your root password and hit enter. Type the following SQL command and hit enter :
CREATE USER ‘phptest’@'localhost’ IDENTIFIED BY ‘phptest’;
Then type this SQL command and hit enter :
FLUSH PRIVILEGES;
Now type this SQL command and hit enter :
SELECT Host, User, Password FROM mysql.user;
 

As you can see we have now created a new MySQL user account called ‘phptest’ with a password of ‘phptest’. This user account can log in to MySQL but has not been granted any permissions on any of the existing schema or databases.

Configure PHP for MySQL Connectivity

Now that we have got both PHP and MySQL installed on the server we can move on to the job of getting PHP connected to MySQL. The first thing we need to do is enable the MySQL extensions for PHP to use. To do this locate the Dynamic Extensions section of your ‘php.ini’ file and either uncomment or add the following lines to the top of the existing list of extensions :

extension=php_mbstring.dll
extension=php_mysql.dll
extension=php_mysqli.dll

You may find that the line referencing php_mysqli.dll is not in your php.ini file - if not you will need to add it to the list. Once you have done this save the changes in the ‘php.ini’file and then either recycle your PHP web site’s application pool or perform an IISReset for the changes to take effect. If you now browse the http://localhost/index.php file we created in the first article you should see that support for MySQL is now enabled.


We are now ready to go ahead with a simple test script to ensure everything is setup correctly. Start by creating a new text file in Notepad in the root of your PHP test web site and then type in the codes and save it as 'dbtest.php'.
<?php
// Establish a connection and select a database
$link = mysql_connect('localhost', 'phptest', 'phptest') or die('Could not connect to the MySQL Server: ' . mysql_error());
mysql_select_db('mysql') or die('Could not Select the Database.<br><br>The error returned by MySQL was: <br>' . mysql_error());
// Close the connection
mysql_close($link);
?>
Browse to http://localhost/dbtest.php on your server. You should see the error message shown below.

 

his indicates two things. First, that we have successfully connected to MySQL from our test PHP script and second, that the user account we specified in our connection string does not have sufficient privileges to access the ‘mysql’ system database. So you should now have a working installation of PHP and MySQL running on your IIS 5.1 server. In the final article in this series I will demonstrate how to install phpMyAdmin in IIS 5.1 and PHP 5.3. Thanks again for sticking around! If you have any comments, questions about the installation and suggestions please feel free to post here.