Not able to connect to mysql via php script , but can login to phpmyadmin in LAMP UBUNTU -
Not able to connect to mysql via php script , but can login to phpmyadmin in LAMP UBUNTU -
i trying connect mysql using php in ubuntu lamp. can login phpmyadmin , not able connect using php code. code working in xampp .
i using next code
$con=mysql_connect("127.0.0.1","myusername","mypassword"); if (!$con) { die('could not connect: ' . mysql_error()); }
but shows next error
could not connect: access denied user 'root'@'localhost' (using password: yes)
there 3 (that know of) posible solutions depending on problem.
there firewall in ubuntu need open, granting access in iptables.
/sbin/iptables -a input -i eth0 -p tcp --destination-port 3306 -j take , should able login our server our local machine:
mysql -h255.112.324.12 -uroot -pmypassword
you need grant access mysql: http://askubuntu.com/questions/159053/mysql-server-not-accessible-from-remote-machine
as root, open /etc/mysql/my.cnf favorite editor [mysqld] section, , in there bind-address keyword. set 127.0.0.1 -- alter match "normal" ip-address save file, , reload service (e.g. using service mysql restart)
last not to the lowest degree need give remote access in mysql:
grant on mydb.* root@'%' identified 'mypassword';
source: http://web.archive.org/web/20120930214828/http://chosencollective.com/technology/how-to-enable-remote-access-to-mysql + many sleepless nights.
php mysql ubuntu lampp
Comments
Post a Comment