I have been close to the crash, ask you to answer the next Mamp Environment Connection database and system settings of a few small problems, not very grateful

Source: Internet
Author: User
I am close to Ben Collapse, ask you to answer the next Mamp environment connected to the database and system settings of several issues, not very grateful!
Overview: Recently learning PHP programming, System for Mac OS X 10.11, using Mamp PRO (3.1) Integrated environment

Problem: in Mamp folder htdocs into the simple echo PHP code can be displayed, but unable to connect to the database, as follows,
For example, follow the instructions in the Mamp home page to enter the test code for the database connection:

$user = ' root ';
$password = ' root ';
$db = ' inventory ';
$host = ' localhost ';
$port = 8889;

$link = Mysqli_init ();
$success = Mysqli_real_connect (




$db,
$port
);

http://localhost:8888/Web page shows a blank, without any hint.

Test the following code again

$host = ' localhost ';
$user = ' root ';

$database = ' MySQL ';
$port = 8889;
$socket = ':/applications/mamp/tmp/mysql/mysql.sock ';

$DBC = Mysqli_connect ($host, $user, $password, $database, $port, $socket) or Die (Mysqli_connect_error ());

Page display: No such file or directory


Then test the following code:
 
  

{
echo "OK";
}

{

}
?>

Zend Display Warning:mysql_connect (): No such file or directory in/applications/mamp/htdocs/tags.php on line 2
Ok
But the localhost shows false, what the hell is this?

I was puzzled by the problem for 2 days, the root user of the switching system tried, as did not respond.

For the first time I tried to run mysql-uroot-p in the terminal.
Show-bash:mysql:command not found
Try to turn off the Mamp boot system comes with the same MySQL display-bash
Follow the online inquiry http://zhidao.baidu.com/link?url= 0fkwdsfntdwu3wwzvjpgy0l-dfpwzkadieg7gwia9ojwyor5eybvbwfnapdkpbasgsgxrfytstmjgucymj0ipk-i5sqkmg66ugqshrl2c43 Attempted to change the password although the change was successful, but no matter how many times the password has been displayed.

Will the Mac bring MySQL conflict with Mamp MySQL?

I have tried to solve as much as possible, but limited ability can only ask you, really want to do something with PHP, helpless card here please help, 100 points, thank you!
------to solve the idea----------------------
Open the error log to see the error
See if PHP has MySQL extensions installed
Check to see if MySQL starts, and listens for port numbers.
------to solve the idea----------------------
Mac is useless, it is recommended to install a virtual machine, install Windows system, download using WAMP environment.
------to solve the idea----------------------
Your two-piece code, one for Mysqli_connect, the other for mysql_connect
What the hell are you using? Use both of these to install the Php-mysql php-mysqli extension.


Phpinfo ();
?>


Look at the output of the content in there is no MySQL with mysqli extension, if there is no indication that the installation was unsuccessful. The two extensions need to be reinstalled.
------to solve the idea----------------------
I don't know about Mac, but command not found this thing is a little familiar. It seems that the problem of system environment variable
------to solve the idea----------------------
The landlord's Mac is estimated to have two PHP versions, according to the extension is php56, the other is Php55
Look
Php-v
/usr/local/bin/php-v

See if it's the same, if not the same, that's the problem.

Just connect the/usr/local/bin/php soft to the PHP path that you have installed.
------to solve the idea----------------------
Turn on the error message first:
Ini_set (' display_errors ', ' on ');
Error_reporting (E_all);

Let's see what the error message is.
  • 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.