create linked server to Mysql Cpanel - php

I've created an ODBC connection to my MySQL cPanel. I've made the settings in System DSN and when I press TEST Connection the message that returns is succesful. I've added the IP as a wildcard. Then I'm going in the SQL Server Management Studio to create the linked server. I fill up with the dates, I choose "Microsoft OLE DB Provider for ODBC drivers", but when I press OK the following error is showing up:
The linked server has been created but failed a connection test. Do
you want to keep the linked server?
Cannot initialize the data source object of OLE DB provider "MSDASQL"
for linked server "GRUPSAPTE". OLE DB provider "MSDASQL" for linked
server "XXXXXXX" returned message "[MySQL][ODBC 5.1 Driver]Access
denied for user 'gsapte'#'XXXXXXXXXX' (using password: NO)".
(Microsoft SQL Server, Error: 7303)
I've created many linked servers for localhost but when I'm trying to create for my webserver it shows the error above. Do I have to make some changes to the webserver or some access things?
Any advise will be much appreciated.

have you checked that the IP address you are coming from is allowed for the login? When I have used MySQL in a hosted environment, the mysql server checks if the user who is requesting access is coming from a known\permitted IP address. Don't know if this is the problem, just one similar to what you are asking.

Related

connect mysql database in cpanel server in local running laravel application

I have developed POS using the laravel framework. I want to connect my hosted account MySQL database local running laravel application. please help me to way to save data in cpanel MySQL server.
You need to enable mysql remote access in your cpanel.
Log into cPanel. Click the Remote MySQL button in the Databases
section. Enter the remote IP address in the Add Access Host section.
Click the Add Host button. You will then see a message stating the
host IP address was added to the access list.
For more with images i have found https://www.inmotionhosting.com/support/website/databases/setting-up-a-remote-mysql-connection-in-cpanel
Sorry i cant write as comment because of rep.

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! :)

Can't connect to mysql server

I'm creating a php page (on a godaddy server) which needs to connect to a mysql server and retrieve data from a database. When i run the page i got an error message stating that.
Warning: mysql_connect() [function.mysql-connect]: Can't connect to MySQL server on **
It says that the error is on the below line,
$conn=mysql_connect($dbhost,$username,$password);
My doubt is,
What needs to be given in place of username and password? Right now i've given the username and password used while creating a new database inside mysql. What am i doing wrong?
Thanks in advance...
Do not use "localhost" as the hostname for your database-driven websites. Once you have successfully created a database, your host name displays on the Database Information page of your hosting Control Panel.
To Find the Host Name for Your Database
Log in to your Account Manager.
Click Web Hosting.
Next to the hosting account you want to use, click Launch.
In the Databases section of the hosting Control Panel, click MySQL or MSSQL depending on the database type for which you want the host name.
From your list of databases, click Actions next to the database you want to use, and then click Details.
Your database host name displays in the Hostname field.
On shared go daddy DB's you can't use localhost for the $dbhost
you will need to use the location specified in your godaddy mysql cp

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.

Can't connect to a database (server) via MS SQL PHP Generator

I'm using the software called "MS SQL PHP Generator" which connects to a remote database from my machine.
I specified the correct username, password and server name.
However, I am unable to connect: getting an error saying "Connection not allowed or server doesn't exist".
Is there a configuration I must set up in the MS SQL Server Managment Studio? The software we're using to manage the database.
Here's a pic: http://img860.imageshack.us/img860/3096/so1zc.jpg
Edit: In the SQL managment studio I wen't to permissions, and I saw that my account doesn't have the persmission "Connect SQL". Could this be the issue?
No, you do not have to connect as sa - rather, you should NOT. Make sure to grant the account you are connecting with access to the database to are connecting to. For example, create a new database named TEST. Then, create an SQL Server login named test_user. When you create the user, select the User Mapping tab (over on the left of the window) and check the box next to database TEST. Down below, set the account to be in the db_datareader role. Now try connecting via code. There's nothing to query, but you should establish a connection to database TEST.
You also have to make sure that the remote SQL Server: allows remote connections, is not behind a firewall, is not running on a port other than the default 1433, etc, etc.

Categories