Configure Php+apache+phpmyadmin+mysql remote link under Mac

Source: Internet
Author: User
Tags phpmyadmin

The most recent project is the development of the public platform, the official demo is PHP, found that most of the learning material is also PHP, then well, give up Java, to paragraph PHP bar

Let's talk about setting up a PHP environment under Mac

Database: mysql-5.6.26

OS x:10.11.1

Apache : 2.4.16

phpmyadmin:4.5.2

Editor: Sublime TEXT3

Apache:

The Mac system already comes with, open "terminal" input:

-V or  and password

You can see the version information that comes with your system:

Server version:apache/2.4.  - (Unix) Server built:     A  - *:£ º

Here are the basic commands:

// Launch Apache Service sudo apachectl Start // Restart Apache Service sudo apachectl Restart // Close Apache Service sudo apachectl stop

Configure Apache to add support for PHP

1 . Edit the http.conf configuration file with the following terminal: sudo vim/etc/apache2/http.conf2. Remove the comment from the following section: LoadModule php5_module libexec/ apache2/libphp5.so (i.e. remove the previous #)3. Restart Apache service:sudo apachectl restart

Next, open directly with the browser http://localhost the following page appears, that is, the configuration is successful

Now you can write a php file yourself, test1.php put in,/ library/webserver/documents under

Open Browser, http://localhost/test1.php

PhpMyAdmin:

The following configuration phpMyAdmin, I do not know this thing has what eggs, accustomed to the terminal, as a Mysql-front use?

Download the latest version on http://www.phpmyadmin.net/home_page/downloads.php

To unzip the resulting folder, rename it to phpMyAdmin, and move to:

Create a new config.inc.php file under this folder:

1<?PHP2 3 $i= 0;4 5 $i++;6 7 //I don't know what it's for. 8 $cfg[' Servers '] [$i[' auth_type '] = ' cookie ';9 Ten /*Server Parameters*/ One //The following sentence, after not fully tested, dispensable A $cfg[' Servers '] [$i[' host '] = ' 127.0.0.1 '; -  - $cfg[' Servers '] [$i[' connect_type '] = ' TCP '; the  - $cfg[' Servers '] [$i[' compress '] =false; -  - //if you want to log on without a password, change the false in the following statement to True + $cfg[' Servers '] [$i[' allownopassword '] =false; -  + //If False Then there is no server input box on the index.php page, if the port number is not the default 3306, you will be prompted to log on to the MySQL server A $cfg[' allowarbitraryserver '] =true; at  -?>

You can now open the http://localhost/phpmyadmin/index.php in the browser

MySQL account password, server 127.0.0.1: Port number Direct Login

Here is a small example of PHP access to MySQL:

1<?PHP2 Echo"PHP connection MySQL test </br>"; 3     $mysql _server_name= "127.0.0.1:3307";//Database server name4     $mysql _username= "Root";//Connect to database user name5     $mysql _password= "950906";//Connect Database Password6     $mysql _database= "meal";//the name of the database7     8 //Connect to database9     $conn=mysql_connect($mysql _server_name,$mysql _username,Ten         $mysql _password); One  A      //SQL statement that extracts information from a table -     $strsql= "SELECT * from ' address '"; -     //Execute SQL query the     $result=Mysql_db_query($mysql _database,$strsql,$conn); -     //Get query Results -     $row=Mysql_fetch_row($result); -      +  -     Echo' <font face= ' Verdana ' > '; +     Echo' <table border= ' 1 "cellpadding=" 1 "cellspacing=" 2 "> '; A  at     //Show Field names -     Echo"</b><tr></b>"; -      for($i= 0;$i<Mysql_num_fields($result);$i++) -     { -       Echo' <td bgcolor= ' #000F00 ' ><b> '. -       Mysql_field_name($result,$i); in       Echo"</b></td></b>"; -   } to   Echo"</tr></b>"; +     //Navigate to the first record -   Mysql_data_seek($result, 0); the     //Loop Out Records *    while($row=Mysql_fetch_row($result)) $   {Panax Notoginseng       Echo"<tr></b>"; -        for($i= 0;$i<Mysql_num_fields($result);$i++ ) the       { +         Echo' <td bgcolor= ' #00FF00 > '; A         Echo $row[$i]; the         Echo' </td> '; +     } -     Echo"</tr></b>"; $ } $  - Echo"</table></b>"; - Echo"</font>"; the     //Freeing Resources - Mysql_free_result($result);Wuyi     //Close Connection the Mysql_close($conn);  -?>

PHP page Effects:

MySQL Remote connection:

Now, the problem comes, the actual development of course is to access the server MySQL.

Let's say, set up remote access for MySQL, as an example of Windows Server 2012+mysql-5.0.67:

Use "GRANT all privileges on%s1.* to%[email protected]'%s3'%s4' The name of the database can be remotely connected, if access is allowed to all the '*' %s2 for remote connection user name%s3   Restricts the address of the IP that can connect to the database, without limiting the password that can be '% '%s4 for remote connections
Finally use "flush privileges;" command to refresh the permission that you just modified to take effect.

This can be accessed through phpMyAdmin, but the MySQL version of the test is too low to appear:

Configure Php+apache+phpmyadmin+mysql remote link under Mac

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.