Configuration ODBC for MySQL in Windows - php

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.

Related

Prestashop 1.7 on FreeNAS 9.10 Cannot Connect to Database Server via browser

Scenario
I am attempting to install Prestashop 1.7 on a local FreeNAS server, so that I can have a development environment to design and test custom modules before applying them to my live remote-hosted instance of Prestashop. I get to the database connection stage of the installation process, and receive this error:
Database Server is not found. Please verify the login, password and server fields (DbPDO)
Steps Taken
To ensure all was setup properly, I ran the following queries on the MySQL console:
CREATE DATABASE 'prestashop'
DEFAULT CHARACTER SET latin1
COLLATE latin1_swedish_ci;
CREATE USER 'adminuser'#'%'
IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.*
TO 'adminuser'#'%'
WITH GRANT OPTION;
FLUSH PRIVILEGES;
I understand the security implications of granting all privileges on all databases to a user from anywhere, but I did it this way temporarily for testing in a closed environment (i.e. no WAN access). In my browser during the system configuration stage of the install process, I entered the following for the database configuration form:
Database server address: [IP address of the MySQL server]
Database name: prestashop
Database login: adminuser
Database password: password
Tables prefix: ps_
This generates the same error as before. I am able to establish a connection to the MySQL server using dbForge Studio Express for MySQL using the same criteria. From this, I know that my connection details are correct, but that for whatever reason, Prestashop cannot connect.
Environment
Here are stats for my environment that may be useful in determining the cause:
Server OS: FreeNAS 9.10.2
In a FreeBSD jail
DB Server: MySQL 5.6.39
Web Server: Apache 2.4.29
PHP Server: PHP 5.6.33
Considerations
I have searched (i.e. googled) extensively, and mostly all the causes found were by folks accidentally entering errant parameters. This is not my case, as I have tested the parameters with dbForge.
Questions
What is causing this issue?
What steps have I missed in trying to resolve this issue?
Is there any pertinent information I am missing which could help solve the issues?
Only thing I can think of is that you're entering the wrong IP address.
If you're connecting to database remotely with app, then yes you connect with proper IP but if your Apache/PHP server is running in the same environment as MySQL server then the server address should be localhost or 127.0.0.1.

cant connect opencart to mySQL database

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'

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 connect to remote mysql database with php?

I have a website and a database on a host. But I want the administrator panel on my laptop? Is it possible connect remotely? How can I do this? Thank you very much!
If I've understood correctly your question, you're looking for a GUI front-end for a remote MySQL database. There's many MySQL front-ends out there, but two I would recommend are the official MySQL Workbench if you're running Windows or Linux, and Sequel Pro if you're running Mac (MySQL Workbench can also run on Mac, but I personally prefer Sequel Pro). Both are free.
The first thing you should try is simply connecting to the remote MySQL server by the command line.
$ mysql -u your_user -h remote.host.name -p
Depending on the output will determine what you need to do next.
Error 1
ERROR 2003 (HY000): Can't connect to MySQL server on 'remote.host.name' (113)
This means that the port is not even open for an external machine to connect to it, so you will need to add whatever port MySQL is running on to your firewall to accept incoming connections.
Error 2
ERROR 1045 (28000): Access denied for user 'your_user'#'your.host.name' (using password: YES)
Assuming that your login credentials are correct, this means that you need to grant permissions from within MySQL. Connecting locally from the remote server, grant permissions like this:
GRANT ALL ON your_database.* TO your_user#'your.host.name' IDENTIFIED BY 'your_password';
Obviously substitute all of the relevant things to what they should be.
When you can connect by command line, connecting by PHP is as simple as using the hostname, username and password information that you used in the mysql command above.
You can use a piece of software called Chive to do this, however it's possible that your server doesn't accept connections remotely.
You can either install Chive locally on your machine and connect to the remote computer, or install Chive remotely and connect to it via HTTP (though I strongly recommend HTTPS).
http://www.chive-project.com/
Wow, just like you connect to the site, you should only change the authentication data if necessary, and external IP mysql.

mysql_connect() works fine on localhost but not when accessing seperate ip

I'm working with my University's Systems Administrators to get a LAMP stack setup for me. I'll need to access this server from several websites that I'm working on and I'm having some issues.
So to keep thing's clear:
LAMP Server URL = https://mysqlserver.edu
School URL = https://schoolsite.edu
When I run mysql_connect() on the LAMP Server it connects fine:
mysql_connect('localhost', 'user', 'password'); Works great!
However, when I run mysql_connect() on the School URL I can't connect:
mysql_connect('mysqlserver.edu', 'user', 'password');
Warning: mysql_connect(): Unknown MySQL server host 'mysqlserver.edu' (1) in /home/content/x/x/x/xxx/html/testconnect.php on line 3
Unknown MySQL server host 'mysqlserver.edu' (1)
What do I need to ask the System Administrator to do in order to give my PHP scripts on external sites access to the MySQL server?
Does the SSL complicate issues?
I appreciate any insight you might be able to provide.
Unknown MySQL server host probably means that your machine cannot resolve to hostname mysqlserver.edu, have you tried connecting via IP address?
After you make sure you are resolving the name, you have to overcome three further barriers:
firewalls as others have shown,
MySQL server configuration which has to allow remote connections and
a user able to connect remotely has to be setup.
MySQL user depends on the computer it is access from. 'root#localhost' is not the same root as 'root#192.168.0.156'. So you have to add the user from the computer you are going to access from. So let say the computer where php script is served is '192.168.156' you need to add a user 'user#192.168.0.156' to the MySQL server and don't forget to set the privilege for that user to access to the database needed.
Hope this helps
It's rare to make a MySQL connection over a public WAN. It's common to take a LAN hop or two but you usually can't cross a firewall for security reasons. That is, incoming TCP connections to port 3306 are being blocked by the firewall or gateway onto the local LAN where mysqlserver.edu is.
The canonical test for this is:
$ telnet mysqlserver.edu 3306
I can predict that this will not work. ("Work" means that it reports "Connected to..." and outputs some gibberish.) You have several choices:
run the database locally, or at least nearby. I mean, it's not a LAMP stack unless it has MySQL. :-) This is what approximately everyone does.
use a tunnel / VPN solution of some kind to get through the firewall and to port 3306
open up 3306 on the firewall. You probably will not get cooperation on this.
Is "skip-name-resolve" option enabled in your my.cnf?

Categories