"Localhost Error establishing a database connection " - mysql

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.

Related

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.

How to make a mysql server publicly acessible with MySQL Workbench?

So I am developing an app that I want to let include server interaction. I have installed MySQL server and MySQL Workbench. I am able to query my data base locally from Java. such as local host. but when I change the query correctly, to reference the IP of my server and not "localhost", I am unsuccessful both on my server and separate machine. I have pinged my server from my another machine successfully. I have configured user accounts on MySQL workbench in almost every way possible. I have done a lot of googling with little success.
I am 19 and just starting to learn SQl now. It'sn ot a big part of my project. I am sorry if this sounds like a basic question, but google has gotten me no where and I am really eager to publish my app xP . So I would really appreciate the help or even a basic guide as to what I may be doing wrong.
Most likely, this is because you did not yet assign user permissions for remote computers. You'd have to use something like tyhe following:
GRANT SELECT ON myDatabase.*
TO myUser#’mycomputers.ip.address’ IDENTIFIED BY ‘my_password’;
There's a more extensive guide here:
https://support.rackspace.com/how-to/mysql-connect-to-your-database-remotely/

How to diagnose (and repair) persistent mysql errors from a drupal 7 site on an ubuntu 16 server?

I'm deploying a Drupal 7x site to a Digital Ocean Ubuntu 16.04 server for testing and demo purposes. I'm switched the server php versions from php7 to PHP 5.6, but otherwise using the default versions of Mysql and Apache2. I had no problem installing the site and the site functions; however, I frequently have database related errors, specifically, the following one:
PDOException: SQLSTATE[HY000] [2002] Connection refused in lock_may_be_available() (line 167 of /var/www/html/phisigmarho.org/includes/lock.inc).
I typically get that error, but I also get "the website experienced an error" errors or "mysql server has gone away" when I to do anything database or process intensive (updating modules through the UI, etc). I'm relatively new server administration, so I'm not sure what could be wrong or which logs I should be looking at for clues to what's wrong. For the moment, restarting MySQL from the terminal is letting me move forward with setting up the site, but I can't let anyone use the site the way that it is now.
So, how do I figure out why MySQL keeps going away? I'm perplexed, because the server is very similarly configured to my dev machine (ubunutu 16 desktop running php5.6) and I don't have anything remotely similar going on. Where do I look for meaningful logs that will help me diagnose of fix this. So, ideas?
Here are a few things I would try in this scenario.
Install Drush (if not already).
Then see what you get for the following commands:
drush status - check the site configuration looks correct including the DB connection
drush sqlc - this will log you into the MySQL command line using the connection details specified in settings.php. It's worth making sure this connection opens successfully
drush cc all - Clearing your site's caches is always a good idea when migrating to a new environment.
If still not working, I would truncate all the cache_* tables in the Drupal database. I have seen errors similar to above and the normal cache clear wasn't enough to resolve it.
Make sure Drupal Watchdog is enabled. drush en dblog. You can then view watchdog log entries using Drush e.g. drush ws
Check PHP logs. You may need to contact Digital Ocean for location and access to these.

MySQL not connecting with PHP

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

how to find the connection string details for mysql in IIS?

I installed php and mysql on my IIS 7,
Now, I can see the phpinfo() and it all works great, except, I dont know where and what are the connection string details are for mysql.
I am trying to install wordpress (via web platform installer on IIS) and everytime I try to install it, it asks for database details - I understand why its doing that, except, I dont know what they are myself.
After a lot of googling and searching, I am surprised that there are literally NO information on how to do this, no tutorials anywhere, not even bugs on this. Either that, or I'm barking up a different solar system.
Any links to tutorials on how to do this would be very helpful. But most importantly, how do I find the details about mysql?
thanks.
Do yourself a favor and download a proper GUI for working with MySQL, such as SQLYog or something similar and forget that poo of PHPMyAdmin. As mentioned, your username is most likely root without password.
You can search for a program called mysqlinstanceconfig.exe (or something similar, you should have it in your MySQL installation folder) - it allows you to quickly reconfigure your instance and you can reset your login credidentials with it.
About MySQL GUI-s: if I'm not mistaken, there's one free coming directly from MySQL but I'm not sure about that. Forget about PHPMyAdmin, it's the worst piece of code ever written and a HUGE security hole.
As you're running a MySQL server locally, your hostname would be localhost, and you can use root as the username, and put nothing as the password.