1. Authorization
Grant select, insert, delete, update on mydb. * to tan identified by '123 ';
2. open the port
1) disable the Firewall
Chkconfig iptables off
Service iptables stop
Or
2) modify the/etc/sysconfig/iptables file and add
-A RH-Firewall-1-INPUT-M state -- state new-m tcp-p tcp -- dport 3306-J accept
3. phpCode
Code:
Test. php
<? PHP
$ Db_host = "192.168.1.2 ";
$ Db_user = "Tan ";
$ Db_password = "123456 ";
$ Db_name = "mydb ";
$ Company_table = "company ";
$ Link = mysql_connect ($ db_host, $ db_user, $ db_password) or die ("database connection failed ");
$ Db = mysql_select_db ($ db_name, $ link );
$ Query = "insert into $ company_table (company) values (& #39; tansf & #39 ;)";
$ Result = mysql_query ($ query );
$ Query = "select * from $ company_table ";
$ Result = mysql_query ($ query );
$ Total = mysql_num_rows ($ result );
Echo $ total;
?>
Access http: // 192.168.1.4/test. php