I've installed XAMPP on my Windows XP. I started the XAMPP control panel and it shows apache and mysql are running.
When I check the status by going to localhost/xampp it shows:
mysql : deactivated
When I run php files that access the mysql database, it shows the following errors:
Warning: mysql_connect() [function.mysql-connect]: [2002] No connection could
be made because the target machine actively refused it. (trying to connect
via tcp://localhost:3306) in C:\xampp\htdocs\Elo_algorithm.php on
line 18
I've been through the XAMPP troubleshooting page and FAQ but I don't understand what to do. The XAMPP control panel shows mysql is running, but xampp status shows: deactivated.
What is going on here?
OK I got this issue resolved in my case, hopefully will help you too. Problem was system itself. If you run Vista, Win7, win8 you probably have permission issue. Simple go to XAMPP root and find mysql_start.bat and run it. Immediately after clicking your firewall will appear with message asking for permission. All you have to do is to allow permission (for private networks such a home or work network).
MySQL database ACTIVATED - and that's what matters ;)
I hope that helps to all of you who did not get an answer so far.
Cheers!
You should view in the xampp installation the file "\xampp\mysql\data\mysql_error.log".
This file contais the error log of MySQL and in it you can detect any problem like por in use.
For example, this lines of log show that the port 3306 (the mysql default) is used by another application and can't be accessed.
111130 8:39:56 [ERROR] Can't start server: Bind on TCP/IP port: No such file or directory
111130 8:39:56 [ERROR] Do you already have another mysqld server running on port: 3306 ?
111130 8:39:56 [ERROR] Aborting
If all in the MySQL is correct probably the problem is related to the driver in the php application. Currently PHP has two MySQL connector types, the "mysql" and the "mysqli", MySQL "mysql" connector, that use "mysql_" (the method that you are using to connect is mysql_connect) prefixed functions, is used for old MySQL 4 applications and when the MySQL 5.x if is in configured with the "old password" parameter. The "mysqli" is used for the new mysql 5.x versions and in php you must use "mysqli_" prefixed functions like "mysqli_connect.
The version used by the lastest versions of xampp is MySQL 5.5 and you require to used the mysqli connector.
Check whether the value of port variable in the "my.ini" file in your xampp mysql folder is 3306 or 8888
i was facing the same problem. I had to run setup-xampp.bat to make it working.
By the way I came across a new WAMP stack called AMPPS. It looks quite easier than XAMP. You should try. http://www.ampps.com
I could not get XAMPP for Windows (1.7.4 Beta2--I know; ancient) to work on Windows 7 (32 bit) as the MySql would not "activate" or connect to Apache. Just by dumb luck I installed .NET Framework 4.6 for another application and suddenly--Whoopee! It started working!
Related
I had installed MAMP on my windows 10 machine. I had then configured the MySQL thru the phpMyAdmin and had installed the WordPress. Later due to certain issues, I had to un-install and re-install the MAMP again. This time Apache started running and I could reach localhost/MAMP/, but when I click on phpMyAdmin, I get the message:
"mysqli_real_connect(): (HY000/2002) No connection could be made
because the target machine actively refused it
.....You should check the host, user name and password in your configuration and make sure that they correspond to the information given by the administrator of the MySQL server". I ran the command> MySQL -u root -p status. It asked for a password. On giving the password, I got the following: Error 2003 (HY000) Can't connect to MySQL server on localhost (10061).
Please help with a workaround.
The error was resolved thru re-installation and taking care to disable the installation of MAMP Pro which happens by default.
I usually see the "actively refused" error when I try to connect to a port that the MySQL server is not actually running on. That said, I don't know why this would happen out of the blue. Maybe you should be using WAMP instead of MAMP?
You could probably troubleshoot this issue remotely with third party tools that have debug logging (MySQLShell through its Application Log)
Check all your Microsoft Redistribute Packages are installed correctly. If the problem exist then use the XAMPP or WAMP for the Windows because MAMP is generally used for the MAC OS.
i had previously installed xammp and phpstorm but they show this error-
18:05:38 [mysql] Problem detected!
18:05:38 [mysql] Port 3306 in use by ""C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqld-nt" --defaults-file="C:\Program Files (x86)\MySQL\MySQL Server 5.0\my.ini" MySQL"!
18:05:38 [mysql] MySQL WILL NOT start without the configured ports free!
18:05:38 [mysql] You need to uninstall/disable/reconfigure the blocking application
18:05:38 [mysql] or reconfigure MySQL and the Control Panel to listen on a different port
18:05:38 [mysql] Attempting to start MySQL service...
i have read every possible solution on stackoverflow, tried every possible solution but the problem still persists. even myphpadmin shows connection error.
i will be making my first php project( with database connectivity), so kindly tell me the connection code as i want to code in notepad++ using just mysql server 5.0
If you have uninstalled MySql Server 5.0 , uninstall Xampp too. And restart the Computer and again reinstall Xampp. With Xampp you can use PhpMyAdmin. So , I think no need to install MySql Server again. But , If you want you can Install.
If you are doing your First PHP Project , I think it's good to use MVC Structure. You can use MVC to Data Insert , View , Update , Delete and Login. And when you create Login , you should make with Sessions. Otherwise , anyone can access that page without login.
And there is one more thing. There are MySql and MySqli. Both are same. But , latest one is MySqli. So , you should make your Project with MySqli. If you use MySql you can run that Project on the Localhost without any trouble. But , when you Upload your Project to a Server , there are errors like this below picture. But , if you use MySqli you can run Project on Localhost and Server without any trouble.
just like the error says, there's an executable file in C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\ named mysqld-nt already using the ports that your mysql server is configured to use! thus, either reconfigure your mysql server to use different ports, or get rid of C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqld-nt before starting your mysql server. it's been a while since i used xampp, but i think the mysql configuration file for xampp is in C:\xampp\mysql\my.cnf by default. or if you're having problems deleting C:\Program Files (x86)\MySQL\MySQL Server 5.0\bin\mysqld-nt, check out LockHunter: https://lockhunter.com/index.htm
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.
I'm finding myself unable to connect to a MySQL server on my LAN using PHP, and only using PHP. Here's a breakdown of the situation.
My server is at 192.168.0.999 (well, except the 999 is in the 0-255 range of course). It's an Ubuntu server, where I have MySQL 5.5 running that I installed via apt-get.
I am using PHP 4 (no, unfortunately I cannot switch to 5 at this point) on Windows 7
I am connecting using mysql_connect() (and again, no switching to another API is not an option at this point). mysql_error() says: Can't connect to MySQL server on '192.168.0.999' (10061)
I can telnet to 192.168.0.999 port 3306 and although PuTTY gives me an error about packet order, there's quite clearly a MySQL server listening on that port.
I can connect by starting cmd and typing mysql -h192.168.0.999 -uusername -p, (of course my username is not actually 'username') and after I type the password I can run queries.
I've triple-checked the credentials in my PHP script for typos, so I am now quite completely stumped. I understand that error 10061 is a network error and that either MySQL or the box it runs on, is refusing my connection, but I cannot reconcile this with the fact that I can telnet to the very same host, and can connect easily with the standard mysql client on my machine.
Before anyone brings it up, AFAICT I've followed the troubleshooting steps in the MySQL manual to a T and the PHP manual does not seem very helpful. Copying the database to my local machine is very logical, and very desirable, but also very impractical.
Can anyone help me?
You've stated that you are running this on windows, and that you can access MySQL through command line but not PHP.
This sounds like permissions problems - are your table InnoDB by any chance?
If so, check the permissions on the InnoDB database files.
As it turns out, I was connecting to the right host, but to the wrong port. For reasons that are not really relevant to the question, my MySQL instance runs on port 3307 instead of 3306, so I've set mysql.default_port to 3307 in my php.ini file.
Mystery solved: PEBKAC!
I am runing linux mint. I have a mysql db called Test. Do i need apache or something to hook it up to my db?
When i try to do my php myqlconnect i get this:
Warning: mysql_connect() [function.mysql-connect]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
Any ideas? thanks!
In order to make connection to MySQL database from in PHP script, you need:
Correctly configured MySQL server, with user, which has corresponding permissions
Correctly specified parameters in mysql_connect() function
Network connection from host where PHP script is started to host where MySQL database is running
PHP script may be executed either in command-line, or as web application. Obviously, Apache web server is necessary only for the second case.
For your specific error, you may take a look at corresponding questions at ServerFault, for example, at this one.
What you are trying to do is set up what's called a "LAMP" server (Linux, Apache, MySQL, PHP). There are plenty of guides on how to set these up, such as http://www.ubuntugeek.com/step-by-step-ubuntu-810-intrepid-ibex-lamp-server-setup.html
This is not Apache related; it's related to the configuration of the MYSQL server and PHP. The database can be reached via the network or local UNIX domain sockets(depending on configuration). In your case, PHP (via the MySQL client lib) is configured find a socket in /var/lib/mysql.sock.
Check the configuration. Ensure the database is running. Check for the socket in /var/lib/mysql.
BTW on my system, the socket is in /var/run/mysqld/mysqld.sock. That was configured from /etc/mysql/my.cnf.
First of all, you need Apache to run PHP even if you are not making any connections to your database. Usually Apache runs PHP as a DLL and you need to enter some commands in the httpd.conf (configuration) file of your Apache installation. Are you familiar with these?
Second, you have to have the MySQL server already up and running, in order to make a connection to your database through mysql_connect. I am not a Linux user, but in Windows, I have registered MySQL as a service to be started at startup. However, they may well be a way of doing this in Linux as well.
Again, these are for Windows - sorry!
You should replace the paths with the ones you have in your Linux Apache installation and the name of the DLL. And these are for version 5 of PHP (if that is what you are using)
PHPIniDir "C:/Program Files/PHP/"
LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"