Depressed about the problem, very depressed

Source: Internet
Author: User
Depressed problem, very depressed.
There is a server linux+apache+mysql+php another phpmyadmin installed
Use phpMyAdmin to access the server normally
But I wrote php myself.
Connecting the database says the target machine is actively rejecting. Unable to connect ....

    $username = "Test";   
$psword = "123456";
$hostname = "10.12.18.27";


$server _link = mysql_connect ("$hostname", "$username", "$psword")

This sentence will be a problem ...... Mother, there's no justice.
With root or test account, the phpMyAdmin can be logged in normally.
The only difference is that phpmyadmin on the server.
My PHP code is on my Computer (apache+php+win7)
Again test account, what remote login, arbitrary location login function all open ...


------Solution--------------------
No permissions to open MySQL remote connection
------Solution--------------------
You can use SQLyog or command line to connect to see. See if you can connect successfully.
------Solution--------------------
The host entry for the user table in the MySQL database, renamed% from localhost
Or a new add-on record, the host entry is your local IP address, and you authorize
Restart MySQL Service

Rules of Practice:
Using the GRANT command
You want MyUser to use MyPassword to connect to the MySQL server from any host.
GRANT all privileges on * * to ' myuser ' @ ' percent ' identified by ' MyPassword ' with GRANT OPTION;
If you want to allow users to connect to the MySQL server from a host myuser IP 192.168.1.3 and use MyPassword as the password
GRANT all privileges on * * to ' myuser ' @ ' 192.168.1.3 ' identified by ' MyPassword ' with GRANT OPTION;
  • 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.