MySQL not connecting with PHP - mysql

I installed MySQL server and everything worked fine in command line. I worked connecting MySQL to my ASP.NET application and there is no problem at all. But when I try to connect MySQL to PHP applications I am unable to connect. When I installed PHPMyAdmin I am getting error #2002 Connot log in to thie MySQL server
I browsed all the night for this error and none of Google's results helped me! :(
Anybody can you please tell me where the problem is at? I believe I must change my PHP.ini file settings in order to connect to MySQL. Anybody please help me.

There are a lot of things that can cause this type of issue. Did you make sure that you have added php-mysql drivers to your sever. Since you said your using ASP i will assume that you are using windows servers. Make sure that you also are allowing that user to connect via localhost or what ever ip the PHP is on.
In php there are to standered ways of connecting to a MySQL database.
php-mysql(is going to be depercated soon).
php-mysqli(OOP version of the php-mysql with lots of features).
With out one of these php will be unable to work with a MySQL database. I am not sure if phpmyadmin works with both drivers or just one of them It could be throwing a die("message") Just to let you know it is not working instead of throwing a more complex php error. You may want to see if you can incress error reporting.
You can check if your php installastion has the mysql driver by looking in your php.ini and also checking with.
phpinfo();

It is almost always about config. https://bbs.archlinux.org/viewtopic.php?id=90133

Related

First time using phpMyAdmin but getting multiple error messages about invalid connection and don't know where to start

screenshot
I am unable to connect to phpMyAdmin. This is my first time using it. These are all the errors I am getting, but I don't understand what any of them mean.
I installed XAMPP, ran Apache and MySQL, selected Admin, but then I get these errors in the screenshot attached.
I am completely new to this. I've been trying to follow a beginner guided project for MySQL on Udemy and the instructor is using phpMyAdmin. But, I couldn't find any instructions on how to install it and so I tried googling it and figuring it out myself. I looked at similar problems posted on here, but I honestly don't know where to start. Any suggestions? Or at least where to start?
I tried going into Config to check host, username, and password, but I am not sure what to look for and how to repair the problem.
I had MySQL Installer - Community and installed MySQL Workbench, MySQL Connector and MySQL Server prior to installing and using XAMPP. I was wondering if that was the problem so I uninstalled all of them, but I got the same errors anyways.

How do I restart a MySQL local instance in MySQL workbench?

I've recently gotten into databases for a class I'm currently in, and I need a little bit of help. I've managed to create a database, and even populate a table with data which I was then able to grab from a node.js project I've made in Atom. Wonderful! When I went to shut it down, all seemed normal but now it won't restart. As in, when I'm in the homepage section of MySQL I double click the local instance I made(I can only assume this is opening the connection to the local instance where my database is stored) but it won't start up. I don't know what I'm doing wrong. Here is an image of the error I'm getting. I can only assume it's because the actual server isn't on but I don't know how to turn it on.
Any help is much appreciated!
Thank you!
As according to the users ikiK, P.Salmon, and Y4glory the issue I was having was that I wasn't actually turning on the server. I was able to do so by going through my Window's Services application, finding the MySQL server and starting it there instead of trying to do so through the workbench.
Once again, thank you to those who commented as that was really helpful!!
I have tried every other way mentioned here and other related posts, but it did not solve my problem, the service just wont start, but the below approach with the mysql-installer did.
For this to work you need to have your installer which you have used earlier to install MySql.
Start your windows mysql installer. For me it was "mysql-installer-community-8.0.20.0"
Then remove/uninstall the SQL Server and remove all configurations
Manually delete the SQL Server folder from "C:\Program Files\MySQL\MySQL Server 8.0."
Start your mysql installer again and install the SQL Server again
You can check now that the MySqL Server has started.
Hope it helps someone.

"Localhost Error establishing a database connection "

I am new to WordPress, and I am trying to setup it at my local machine.
I am getting error like "Error establishing a database connection".please help me to solve this error..
Without your database code, it is hard to figure the exact reason.
The error is usually due to:
Your MySQL server is not running. So you need to run this command if you are on a Linux machine (May not work for Ubuntu):
/etc/init.d/mysqld start
Or,
The MySQL user does not have the privileges to access the Wordpress
database
The port 3306 is blocked. Check what other program is using that
port.
The host name in Wordpress configuration is not correct. Make sure it
is 'localhost'
This is not exactly the proper way to address the problem, it's invaluable to learn how to navigate and work with the wp-config file, Apache, and MySQL - but this should solve your problem, and is very friendly for someone just getting started with this sort of thing.
The correct fix (in my opinion) is to set up a WAMP server, or at least Apache, MySQL, and PHP to run Wordpress locally.
You probably are looking for something more like: http://www.instantwp.com/
I have used it before. Basically, you install and it creates a virtual temporary server where you can develop without needing to mess with the details of Apache, wp-config, or SQL. Very easy, hope that helps. Cheers.

Connecting my MySQL databases to phpMyAdmin

I am running Mac OS 10.10.2. I have recently been educating myself about php and SQL in order to create an online database application for my employer. However, I have been unable to load up my MySQL databases in phpMyAdmin. I have tried following some advice from this forum, but no answers seem to solve my issue.
I installed MySQLWorkbench (Ver. 6.2.4.12437) as well as XAMPP (Ver. 5.6.3-0), and was using phpMyAdmin to have a play around and better understand what I was getting myself into. I then found one of those follow-the-bouncing-ball type teaching websites which advised me to download and install the MySQL community server (Currently running Ver. 5.6.23)
As instructed, I was learning SQL commands through Terminal and built up some databases/tables this way. I decided I wanted to jump into phpMyAdmin where I felt it'd be easier to continue my work. At first XAMPP was unable to turn on the servers which I overcame by uninstalling and reinstalling. Then I was getting a #2002 error when trying to access phpMyAdmin. I tinkered with config files and put in details relating to my localhost MySQL server (Or at least I assume as much).
I was able to get back into phpMyAdmin finally, but my databases made through terminal are not there.
phpMyAdmin shows: cdcol (the example database), information_schema, mysql, performance_schema, phpmyadmin, and test.
If I open terminal and punch in 'mysql' then 'SHOW DATABASES;' it only lists: information_schema.
If I open terminal and punch in 'mysql' with username 'root' and my password, then 'SHOW DATABASES;' it lists: information_schema, mysql, performance_schema, my tutorial/learning database, and my business database. I dropped the test database from here. THESE are what I want to bring up in phpMyAdmin.
I can only guess that I haven't got it configured properly to access this last mysql server, but I can't determine where I am going wrong. If anyone can shed some light on this, that'd be greatly appreciated.
It appears as if you have two MySQL instances; one from the XAMPP and also the MySQL Community Server that you installed yourself.
The "M" of XAMPP is for MySQL, so yes usually it runs its own MySQL server instance. That's sort of the point of the packaged kit, so you don't have to worry about having any of your own applications installed. In theory it should be no problem to stop the XAMPP MySQL instance and instead use your other one, but may require tweaking some configuration files and is probably not supported. If you can make it work, I don't see a reason why it would be a problem, though.
My suggestion is to either use the complete XAMPP stack or roll your own installation rather than mix and match.

connection refused mysql node.js

I've tried everything under the sun to fix this problem, nothing works!
I'm trying to connect to mysql using node.js.
I've tried both normal connections and pool connections, but I keep getting the following error:
"connect ECONNREFUSED"
I'm working on a Windows 7.
There are many similar questions to this on Stack Overflow, and everyone mentions the mysql configuration file (and commenting out "skip-networking"), however, I can't find where the file is (the mysql module was installed under node_modules).
I've tried looking for my.ini and my.cnf, there don't seem to be on my machine either.
Is there a way to try to log in to mysql via the command line?
It seems like there isn't since the command line doesn't recognize the command "mysql".
I'd post the code that I've been using but that wouldn't help, since I've been using dozens of different alterations, and all fail.
Thanks in advance, I appreciate the help!
Thanks to Салман, I realized that I need to install the actual MySQL server as well.