Depressing. -Php Tutorial

Source: Internet
Author: User
Depressing. One server, linux + apache + mysql + php, is installed with phpmyadmin.
Use phpmyadmin to access the server
However, I wrote my own php
The connection to the database says the target machine is actively rejected. Unable to connect .......

    $username = "Test";       $psword = "123456";      $hostname = "10.12.18.27";      $dbName = "TestDb";     $server_link = mysql_connect("$hostname","$username","$psword")              or die("Can't connect to server" . mysql_error()); 

There is a problem with this sentence ............. Oh, no.
With the root account or Test account, you can log on to phpmyadmin normally.
The only difference is that phpmyadmin is on the server.
My php code is on my computer (Apache + php + win7)
Besides, the Test account, what remote login, and any location login function are all enabled ......


Reply to discussion (solution)

You are not authorized to enable mysql remote connection.

You are not authorized to enable mysql remote connection.
Do you mean User rights?
%
Localhost
127.0.0.1
Host Name

These four are all open.

Previously, it was normal.
The server is restarted.
That's it.

You can use sqlyog or the command line to connect. Check whether the connection is successful.

You can use sqlyog or the command line to connect. Check whether the connection is successful.
Code 2003

Host entry of the user table in the mysql database, renamed from localhost to %
Or add a new record. the host entry is your local IP address and is authorized.
Restart mysql service

Rules:
Use the GRANT command
If you want myuser to use mypassword to connect to the mysql server from any host.
Grant all privileges on *. * TO 'myuser' @ '%' identified by 'mypassword' with grant option;
If you want to allow myuser to connect to the mysql server from a host whose ip address is 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;

Host entry of the user table in the mysql database, renamed from localhost to %
Or add a new record. the host entry is your local IP address and is authorized.
Restart mysql service

Rules:
Use the GRANT command
If you want myuser to use mypassword to connect to the mysql server from any host.
Grant all privileges on *. * TO 'myu ......

I cannot understand why.
I deleted the account test and created another test. the permissions are the same.

%
Localhost
127.0.0.1
Host Name

Reference reply from xuzuning on the 5th floor: host entry of the user table in mysql database, renamed from localhost %
Or add a new record. the host entry is your local IP address and is authorized.
Restart mysql service

Rules:
Use the GRANT command
If you want myuser to use mypassword to connect to the mysql server from any host.
Grant all privi ......
Restart MYSQL again.

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.