While I've been working with MySQL for years, this is the first time I've run across this very newbie-esq issue. Due to a client demand, I must host their website files (PHP) on a IIS server that is not running MySQL (instead, they are running MSSQL). However, I have developed the site using a MySQL database which is located on an external host (Rackspace Cloud). Obviously, my mysql_connect function is now bombing because MySQL is not running on localhost.
Question: Is it even possible to hit an external MySQL database if localhost is not running MySQL?
Apologies for the rookie question, and many thanks in advance.
* To clarify, I know how to connect to a remote MySQL server, but it is the fact that my IIS web server is not running ANY form of MySQL (neither server nor client) that is giving me trouble. Put another way, phpinfo() does not return anything about MySQL. *
Yes, you can use a MySQL database that's not on the same machine as Apache+PHP.
Basically, you'll connect from PHP to MySQL via a network connection -- TCP-based, I suppose ; which means :
MySQL must be configured to listen to, and accept connections on the network interface
Which means configuring MySQL to do that
And given the required privileges to your MySQL user, so he can connect from a remote server
And PHP must be able to connect to the server hosting MySQL.
Note, though, that habing MySQL on a server that's far away might not be great for performances : each SQL query will have to go through the network, and this could take some time...
If phpinfo is not returning anything about MySQL you need to install the MySQL plugin for PHP, easiest way to do that probably is to just upgrade PHP to the latest version. If not there is a .DLL file that you will need.
http://www.php.net/manual/en/mysql.installation.php
you will need to install the mysql extensions. this link should help: http://php.net/manual/en/install.windows.extensions.php
The MySQL server has nothing to do with PHP itself. What "mysql support" in PHP means is that it's been compiled with (or has a module loaded) that implements the MySQL client interface. For windows, it'd be 'mysql.dll', and on Unix-ish systems it'd be 'mysql.so'. Once those are loaded, then the various MySQL intefaces (mysql_xxx(), mysqli_xxx(), PDO, MDB2, etc...) will be able to access any MySQL server anywhere, as long as you have the proper connection string.
Related
I am new to working with servers, and am not able to use SQLYog because it is not able to connect to any server. When I try to use the default values to connect to MySQL (localhost, root, port 3306), I get "Error No. 2003: Can't connect to MySQL server on 'localhost' (0).
Is there something I am missing or that I have to correct? I am just trying to create a database.
SQLyog is just one way to connect to a MySQL database and interact with it. Other popular methods include MySQL Workbench, Navicat, phpMyAdmin, and others.
Before you can use any of these, you have to first make sure your MySQL server is running and accepting connections. You didn't mention (or tag) whether you are running MySQL on your local machine, or what operating system you are using.
A couple of the most common development environments are LAMP or WAMP, for "Linux, Apache, MySQL, php" or "Windows, Apache, MySQL, php" respectively. Since you tagged your question php, I'll assume one of these is appropriate. (For example you're using SQLyog on Windows but your MySQL server is on Linux.) (I'll presume Ubuntu for Linux examples.)
On the machine you've installed MySQL (along with any other components), you should be able to determine its running state by looking at your process list (ps aux in Ubuntu, tasklist or Task Manager (GUI) in Windows).
You're looking for mysqld (Linux) or mysqld.exe (Windows). If the process isn't running, you need to start it (Linux/Windows). If you're using WampServer (a popular Windows all-in-one package), for example, you can also look in your Windows Services for "wampmysqld" or "wampmysqld64" and start the service there.
If you can't get the process to start, you may have a configuration error. If the process is running, you may need to check the configuration any way to determine what port it is running on, if it's not the standard 3306.
The configuration file name and location can vary by system and package, but generally it will be called "my.cnf" (Linux) or "my.ini" (Windows). Check your documentation for help on the specific path.
Once you've got the service running, you should be able to connect!
This is the default SQLyog connection dialog (at least in my slightly older version). The defaults assume you are running your MySQL server on your local machine (localhost), that you have a user "root" with no password, and the default port 3306 is used.
You'll need to change any of this information that differs on your particular installation.
Be aware that if you're trying to connect to an instance of MySQL on another machine, a firewall may be blocking a port.
These steps should hopefully get you on the right track.
my WordPress site is not loading, it's getting this error:
Could not successfully run query (SELECT name, value FROM wp_simple_shortcodes WHERE 1) from wp_simple_shortcodes: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'(13)
I am told it is because MySQL extension is now deprecated.
My WordPress (and plugins) are up to date so should be running MySQLI already. My hosting company said I need to update my code from my MySQL to MySQLI to fix the issue. But I never wrote any custom code for this site at all and I am a complete beginner with PHP.
What files do I need to update? How can I fix this?
It's more likely this has something to do with the database server running on the webserver of your hosting company. Maybe they've updated the MySQL server version or they changed some PHP settings.
You should ask them to check the PHP and MySQL config settings and to restart both the webserver and the database server. That should fix it.
I am trying to automate the backups of our MySQL databases.
The databases are hosted on shared servers, and can be restarted at anytime, which mean CRON jobs won't be persistent (according to support at my web hosts).
I am currently running the jobs manually via MySQL Workbench at given intervals.
I am trying to automate this process, but I cannot fathom how to do it. There seems to be no options in MySQL Workbench, and Google seems to yield nothing.
I have attempted to run mysqldump on my local machine, with the view to creating some kind of script to do this from my machine. But I get an error - mysqldump: Got error: 2049: Connection using old (pre-4.1.1) authentication protocol refused (client option 'secure_auth' enabled) when trying to connect - which I can't seem to disable at the server end or override at my end.
Any advice?
The standard automatic backup for MySQL is the socalled "MySQL Enterprise Backup" (MEB). MySQL Workbench works with MEB, but as the name indicates this solution is only available for MySQL enterprise servers.
Another solution would be to run a cron job on the target server (using mysqldump). Missed jobs will be executed after the system is up again, so this is a reliable solution too.
If you cannot install a cron job on the target machine then you will have no choice but to manually trigger the backup either with MySQL Workbench or on the commandline.
Error: No Database Selected
I have a website that was hosted with ARVIXE (windows 2008 server) and presently with IXWEBHOSTING (windows 2003 server). It was very simple to move. It was a matter to just download/upload the site PHP files and export/import MySQL database and change the config PHP file to point to the new
database information and voila!
Now I am trying to move the site to my own server. Trust me I have no problems with DNS, servers, networking stuff. I've being doing this for 15 years (not programming).
This is my actual server: Windows 2003 STD SP2, IIS6, PHP5.2.12, MySQL 5.0.96, FastCGI 1.5. and all MS Updates.
Now here me out before you conclude that is the code or MySQL permissions... I have read I think all the No Database Selected errors on the Internet including here and is usually a little code modification or missing code or permission issue on the database...but not this one, see the scenarios below and you will see why not.
Scenario 1
PHP Files are sitting in the IXWEBHOSTING servers. The config PHP file points to my own MySQL server it works fine.
Scenario 2
PHP Files are sitting in the IXWEBHOSTING servers. The config PHP file points to IXWEBHOSTING MySQL server it works fine.
Scenario 3
PHP Files are sitting in my Win2k3 servers. The config PHP file points to IXWEBHOSTING MySQL server, I get error "No database selected".
scenario 4
PHP Files are sitting in my Win2k3 servers. The config PHP file points to my own MySQL server, I get error "No database selected".
So I know for a fact it has nothing to do with MySQL permission on my own MySQL server or PHO code as scenario 1 proves it. It seems to be a problem with PHP on my server.
Prior of installing the OLD PHP and MySQ, I had the lastest version of each PHP 5.3.13 and MySQL 5.5.25 and same FastCGI version. I had the exact same problem!!!! The reason why I installed the old versions is because I wanted to match IXWEBHOSTING server versions.
Prior to the above installations, Windows was installed from scratch each time on a hyper-v server. No updates MS updates were done on the server the first attemps and the last installation it has all the MS updates and I still have the same problem.
I had the same problem with Windows 2008 STD, PHP 5.3.13 and MySQL 5.5.25.
PHP is loading all the proper extensions to make the connections to MySQL. I also have PHPmyAdmin running without problems.
I also tried with in the config file and no luck
There is a lot of stuff in the index but this is what is needed to make the connection to the database and the query and where it fails.
config file
<?
$usuarios_sesion="youth";
$host="localhost";
$user="usernamehere";
$pass="passwordhere";
$db="databasehere";
$tabla="users";
?>
Index.php File
<?
require ("enlaces_config.inc.php");
$menu=mysql_query("SELECT id_cat, name_cat FROM categories WHERE access=0 AND published=1") or die ("Can't select categorias MySQL says: ".mysql_error());
?>
At this point I have no idea what else it can be... permissions, maybe but not in MySQL permission, the user has full priviledges to the database. Scenario 1 and 2 proves it too.
If you need to check PHP information let me know. I will post the name of the php file for excution
Help!
The problem is not with all that you have written w.r.t your server.
When you try to fetch data from a database you must essentially follow these steps-
Create a connection
That involves connecting using Database, User Name, and Password, along with Hostname. You can use mysql_connect(), although deprecated.
You need to select the database from that host.
You go for any mysql query using selected db connection in step 2.
I would suggest you to get a good grip on database concepts first and then implementation using php.
Best place to start http://w3schools.com
I want to connect a MySQL server (a gs server from mediaTemple) to a MySQL server using PHP, I cannot use the mssql_pconnect() function because they don't support it for their gs servers so I'm looking for an alternate route, I don't know if it's even possible.
What I want is to generate a connection on the MySQL server using PHP that will allow me to retrieve certain information from a View on a different server that's running SQL.
They probably don't support mssql_pconnect() because its for connecting to MSSQL and not MySQL, try using mysql_connect() or mysql_pconnect();
You should be able to establish 2 different database connections to 2 mysql servers simultaneously, as long as the host doesn't have some firewall rule that blocks the connection or some other safeguard like selinux.