Phpmyadmin corrupted - php

I'm trying to recover the root password for phpmyadmin. I followed some tricks found on the net, and now I have a deeper problem.
I can't login to phpmyadmin. I'm getting the following error:
\#2002 - Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
The server is not responding (or the local server's socket is not correctly configured).
Connection for controluser as defined in your configuration failed.
I ran the following command to verify if my MySQL is running,
mysqladmin: connect to server at 'localhost'
And I'm getting the following message:
failed error: 'Can't connect to local MySQL server through socket
'/var/run/mysqld/mysqld.sock' (2)' Check that mysqld is running and
that the socket: '/var/run/mysqld/mysqld.sock' exists!
I'm not sure what to do next.

Related

Can't connect to host mongodb from homestead

I have a laravel 5.2 project on homestead 7 which works with mysql and mongodb, I have configured it to connect to host (my mac AMPPS) mysql and mongodb servers.
mysql is connected successfully but I can't connect to host mongodb from homestead.
when I try to connect to host mongodb server from homestead using mongo command I get below error :
vagrant#homestead:~$ mongo 192.168.10.1:27017/admin
MongoDB shell version: 3.2.18
connecting to: 192.168.10.1:27017/admin
2018-01-29T13:18:36.967+0000 W NETWORK [thread1] Failed to connect to 192.168.10.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2018-01-29T13:18:36.968+0000 E QUERY [thread1] Error: couldn't connect to server 192.168.10.1:27017, connection attempt failed :
connect#src/mongo/shell/mongo.js:231:14
#(connect):1:6
exception: connect failed
as you can see my host ip address is 192.168.10.1 and homestead ip address is 192.168.10.10.
And whenever I try to connect to mongodb from laravel mongodb driver I get below error message :
ConnectionTimeoutException in Collection.php line 174:
No suitable servers found (`serverSelectionTryOnce` set): [connection refused calling ismaster on '192.168.10.1:27017']
FYI : I used This shell script to install mongodb and it's driver on homestead 7 with php 7.1
Any suggestion how to fix this ?
The solution to this problem was to edit host /etc/mongodb.conf and set bind-ip to 0.0.0.0
bind_ip = 0.0.0.0
remember to restart mongodb server, then I connected to the host mongodb server.

How can I connect to a postgres database using php via an open ssh tunnel?

I need to connect to a postgres database on a remote server using PHP. I've opened an SSH tunnel on the local machine, local port 8000. The tunnel seems to work fine.
The problem arises when I attempt to connect to the db with PHP. The following code:
$ConnectionString = "host=127.0.0.1:8000 user=username password=passphrase dbname=databasename sslmode=require port=5432";
pg_connect($ConnectionString);
produces the following error:
Warning: pg_connect(): Unable to connect to PostgreSQL server: could not translate host name "127.0.0.1:8000" to address: Unknown host in [path]\mappage.php on line 22
Not connected
How, then, can I open a database connection via SSH?
For what it's worth, I can connect to the remote PostgreSQL database with PGAdmin using SSH.
As written in the manual it should be:
$ConnectionString = "host=127.0.0.1 port=8000 user=username password=passphrase dbname=databasename sslmode=require";
You had port twice and once incorrectly.
Once you've set up the tunnel, you connect to your database via 127.0.0.1. e.g. (MySQL Example):
ssh -L 127.0.0.1:8000:127.0.0.1:5432 sshuser#example.com
After that the connection parameters for my database are:
Host: 127.0.0.1 (localhost would try to connect to socket)
Port: 8000
User: username
Pass: passphrase

Two MySQL local server connect errors

When I try to connect the MySQL database that is on my Mac to a website, I get the following error:
Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
That is when I put localhost as the servername.
When I put 127.0.0.1 as the servername, I receive the following error:
Can't connect to MySQL server on '127.0.0.1' (13)
The following Stack questions did not work for me:
Cannot connect to mysql with 127.0.0.1
error: 'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
First, you should check the status of mysql server:
is that runs?
the difference between tow error is based on allowed mysql connection port over network.

I am unable to use MySQL due to a "refused connection"

I am trying to run the no-install version of MySQL on Windows XP located in C:/mysql/ on my machine.
The error message I receive within a PHP file when I try to connect to MySQL reads.
Could not connect: No connection could be made because the target machine actively refused it
I have edited the config file my.ini and altered/added the following.
[client]
port = 3306
socket = C:/mysql/tmp/mysql.sock
[mysqld]
port = 3306
socket = C:/mysql/tmp/mysql.sock
basedir = C:/mysql/
datadir = C:/mysql/data/
bind-address = 127.0.0.1
skip-networking
enable-named-pipe
When I run mysqld.exe I can confirm it is running within command prompt tasklist.
However when I try cmd netstat -a I cannot see any port usage at 3306.
Inside MySQL error logs, it reads.
140411 13:30:34 [Note] c:\mysql\bin\mysqld.exe: ready for connections.
Version: '5.5.37-log' socket: '' port: 0 MySQL Community Server (GPL)
The port: 0 doesn't look correct to me, but I am not sure.
When I run mysql.exe direct in cmd I get the following returned
ERROR 2003 (HY000): Can't connect to MySQL server on 'localhost' (10061)
Some things I have tried already.
Placing a copy of my.ini in C:/WINDOWS and also a copy within C:/mysql
Changing bind-address = 127.0.0.1 to bind-address =
localhost
Inside PHP file MySQL connection variants, localhost, 127.0.0.1, 127.0.0.1:3306 inside basic mysql_connect()
Created tmp/mysql.sock file (in case dir + file not existing matters)
Commented out skip-networking in my.ini
After running mysqld.exe whilst running ran mysqladmin.exe in cmd which returns 'Can't connect to MySQL server at 'localhost'
Running telnet localhost 3306 returns
'Connecting To localhost...Could not open connection to the host, on port 3306: C
onnect failed'
Commented out bind-address in my.ini to allow default settings.
Ran mysqld.exe with user root (-u root) also inserted user = root in my.ini
Set Windows Firewall to off.
Thanks in advance.
Ok. You have binded your server to specific ip so please read this MySQL bind-addres. Please unbind your server and check if you have proper user. (last paragraph in documentation)

Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)

When i connect my database by a php script it shows
Could not connect: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
the username and password is right.
something of the my.cnf
[client]
#password = your_password
port = 3306
socket = /data/mysql/mysql.sock
# Here follows entries for some specific programs
# The MySQL server
[mysqld]
port = 3306
socket = /data/mysql/mysql.sock
skip-external-locking
ps: i change it to socket = /var/lib/mysql/mysql.sock the php script still says "/var/lib/mysql/mysql.sock"?. then run
mysqladmin -u root -p status
it shows
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists!
service mysqld restart
mysqld: unrecognized service
Q: Does your my.conf still says "/var/lib/mysql/mysql.sock"?
Q: Does the directory "/var/lib/mysql" exist?
Q: Does your mysql user (or better, mysql group) have writer permission?
If so, please try re-starting mysql and see what happens.
ADDENDUM:
One other thing to try is to create a mysql.sock and explicitly give it permissions:
cd /var/lib
mkdir mysql
touch mysql/mysql.sock
chown -R mysql:mysql mysql

Categories