cant connect opencart to mySQL database - php

I'm trying to set up opencart for my website, but when I fill in everything for the MySQL database I get this error:
No connection could be made because the target machine actively refused it.
I've tried putting it on localhost, I've tried on 127.0.0.1. when I try on 192.168.1.126 (the database server) it says it can't find the database
the server hosting the PHP site is on 192.168.1.125
I'm very new to SQL, I really don't understand it fully. I'm creating a new database in SQL workbench. and filling in the info I need. How to I fix this error?

My guess is that your DB user is only allowed to access the DB server from 127.0.0.1. You might want to grant additional privileges to it and in your SQL shell run something like
GRANT ALL PRIVILEGES ON *.* To 'your-db-user'#'192.168.1.125'

Related

Configuration ODBC for MySQL in Windows

I need help to finish the configuration of ODBC for MySQL in Windows. I am receiving different errors, and I have tried several options, but nothing is working. I really appreciate your help.
So basically, we are using MySQL for CiviCRM on Druppal. In order to access the database online, we use two sets of user/password, one for accessing the phpMyAdmin console, and the other one to access the database itself.
I want to configure the ODBC connection so the users could get the information directly in their computers.
These are the steps that I followed:
I installed the ODBC Driver: "MySQL ODBC 5.3 Driver" 32 bits.
I went to the ODBC administration console and configure one system DNS using this driver.
I get the TCP/IP Server directly from the Database Server Information in our phpMyAdmin, and initially I 3306 port.
I type our user for the database (not for phpMyAdmin) and I tested the connection without password. Although it is successful, I just get the databases: information_schema and test, the name of our database is not in the options.
Later I typed our password, and try the connection again, but I get this error:
"Access denied for user USERNAME#LocalHost (Using password: YES)"
In the console I could see that the username is USERNAME#127.0.0.3 and not localhost.
I tried changing port to 3307 because I read somewhere, that it was a possible solution. But I got this error: Can not connect to MySQL Server on ServerName (10061).
Obviously I am not an expert on this matter. I would appreciate your help to configure effectively the ODBC.
Thanks in advance.
I would get back to port 3306 with a mysql daemon restart.
Run thru some of the tests I typed in here at the bottom under the section Why Can't I connect. Look at hostnames.
and the query select user,host,password from mysql.user. You will also see Grants, etc. The grants suggest why your dbname is not seen. There are always a few moving parts to these problems. The fact that you are on 3307 now adds another wrinkle.

Remote mysql connection issue in PHP

I am creating a remote connection using this PHP script from my website to another website of mine. But it is showing errors which says hostname is not allowed to connect to this MySQL serve
Please let me know what I am missing and also tell me if there any other way to access remote MySQL data using a PHP script.
$connect=mysql_connect("hostname","user","password")or die(mysql_error().'Our database is currently down for updates, please check back later.');
You need to explicitly allow the mysql user to connect from the host. For example CREATE USER 'jeffrey'#'localhost' IDENTIFIED BY 'mypass'; will allow the user jeffrey to connect only from localhost.
You can do that via sql commands or phpmyadmin, check the users tab.
You need to grant the mysql user access to your database from the host where the script is running. So if your mysql server is on host server, and the script runs on machine dev, your grant statement would look something like this:
GRANT ALL PRIVILEGES ON database.* TO 'user'#'dev' IDENTIFIED BY 'password';
Does your MySQL database allow remote access to connect? If not, change the configs.
UPD
Tutorial for changing mysql remote access configs

Cannot access MySQL database from my website, but can access via browser?

I'm trying to hook up my website to my MySQL database on my new webhost, and I'm running into a few issues I can't resolve.
If I navigate to mywebsite.com/phpmyadmin/, I'm presented with an HTTP authorization, and upon successful entry of that, my PHPMyAdmin login page, where I can log-in as my user and see my databases. Yet, if I try to connect via PHP through my website, I receive the error:
SQLSTATE[HY000] [2005] Unknown MySQL server host 'mywebsite.com/phpmyadmin' (11)
My connection info is:
$this->dbh = new PDO('mysql:host=mywebsite.com/phpmyadmin;dbname=mydb;charset=utf8','me','myPassword');
I'm running LAMP on Ubuntu 14. Is there any particular reason this is failing?
PHPMyAdmin is a database client application, not a database server.
You need to provide connection information to your database server (which will probably be localhost)
You need to connect to the mysql server rather than the phpMyAdmin interface (won't work).
In this case it's you will use localhost (Really). Why? because localhost just points to the server's local IP. You can also point it to any hostname which points to the server's IP so it knows which server to connect to! :)

How to setup Windows Server 2008 for MySQL remote database connectivity?

I am very new to this server setup and database connectivity. I googled a lot but couldn't find the solution for it.I am developing an android application which needs to post data to remote database. Which is done.
Now i have to setup MySQL Database in the new Windows Server 2008. I have installed and managed to get access the root user(Which is fine). Now i want to access this database from my local computer[Which is iMac]. I already set the privileges by following this link. When i tried to run from my web application it shows the following error.
Error: unable to connect to database. Host 'xx.xx.xxx.x' is not allowed to connect to this MySQL server
Here is my questions
1.) How to get access to the remote MySQL database from any computer?
2.) How to run the web application in the server?Like Web Hosting i.e Do i need to setup ftp account and put the stuff over there?(For Eg: testhost.com/connecttodatabase.php by executing this it will execute whatever code in testhost server. But i have no idea how to do that for my server).
Any help is much appreciated.
Alternately, You can also try...
use the_database_name;
GRANT ALL PRIVILEGES ON
the_database_name.*
TO
'the_user_in_php_code'#'%'
IDENTIFIED BY
'password_of_the_user_in_php_code';
FLUSH PRIVILEGES;
source:
http://forums.devshed.com/mysql-help-4/host-is-not-allowed-to-connect-to-this-mysql-server-366908.html

Linux connecting to mysql PHP

I have been trying to connect to mysql all evening using PHP.
I know for a fact the username and password are correct as I have tried 3/4 and I know the permissions are set correctly in the database.
If I remote onto this machine and enter the exact same details into the commandline then i can connect to the database without issue.
The problem only seems to be with MYSQL and PHP.
A little more info:
I am trying to run a PHP app on the same server as the mysql database is on. The user has full grant permissions on the local machine. The error i am receiving is :
Fatal error: Attempt to connect to database kmc_cms on
The server is set so no remote access to mysql is available.
In your question you don't show whether you're trying IP or localhost.
Do a
show grants for <username>;
and see if the connection you're trying is even allowed.
Have you enabled remote access for the user you're trying to connect with in mysql?
I found out the issue. Within the mysql database config file there was an error which resulted in the connection allowing users from local host access only. Even though the PHP scripts were connecting using localhost it just would not authenticate. Hence I could log in using command line and not using PHP or other applications.

Categories