I've been attempting pretty much all day to get Symfony2's Doctrine configuration screen (e.g. /app_dev.php/_configurator/step/0) to connect to my locally running MAMP-provided MySQL instance. I've spent the day reading about sockets, skip-networking, and every other possible scenario but I'm at a loss. This is the error that you have most certainly seen before:
An exception occured in driver: SQLSTATE[HY000] [2003] Can't connect to MySQL
server on '127.0.0.1' (61)
And here are the various ways I have tried to correct this maddening problem:
I verified that I can indeed connect on the command line to both localhost and 127.0.0.1 using the mysql command. I made sure the ports were both filled in and not so I could see the results of an actual error.
I checked the socket while I was in there via SHOW variables LIKE 'socket' and saw it pointed correctly to my MAMP socket.
I've oscillated between the MAMP default ports and the standard MySQL ports (3306) just in case it was a weird port thing.
I made sure my /var/mysql and /tmp/mysql mysql.sock files were correctly symlinked to MAMP.
I commented out the skip-networking lines in MAMP's configuration file.
I toggled the "Allow Network Access" in every configuration possible
I added the line, unix_socket: /Applications/MAMP/tmp/mysql/mysql.sock, to my config.yml file just in case my symlinking trickery failed me.
I've done several rain dances and other tribal spells I read in a magazine trying to get this to connect.
I'm no stranger to development and MySQL but this has become a lost cause. Any help would be appreciated and rewarded with my unflinching respect for you.
The error code 2003 means "Can't connect to MySQL server", you can try to use the following methods.
Check your config file, is the parameters.yml can be access ? If you are on linux, just sudo chmod 777 /path/to/parameters.yml, and the mysql connection config parameters looks like this:
parameters:
database_driver: pdo_mysql
database_host: 127.0.0.1 or localhost
database_port: null
database_name: yourdbname
database_user: youraccount
database_password: yourpassword
Try to use localhost instead of 127.0.0.1;
Related
I have tried suggestions in what seems like every post about this topic and none of them have worked for me, so I'm posting my own in case anyone spots anything that I missed.
I'm migrating a wordpress site into a LEMP (ubuntu, apache) stack instance on Digital Ocean, and I need temporary access to the database via MySQL Workbench or something similar on my local machine. I'm planning to turn it off once the migration is done. However I am having a very weird issue I can't figure out the cause for.
If I attempt to sign into the sql instance using
mysql -u user -h my.ip.address -p
I can get access from my local machine just fine.
I can also SSH into the server itself via terminal just fine, I have it set up in my ssh config file using the same ip address and the same user and ssh key i'm attempting to use for my workbench connection.
However doing the same via an SSH connection on workbench I constantly get the error:
Authentication failed, access denied.
Failed to connect to MySql at my.ip.address:3306 through ssh tunnel at user#127.0.0.1 with user mysqluser
Things I've done to attempt to rectify this:
set bind-address in mysql config to 0.0.0.0 on the server and restarted server's mysql
set bind-address in mysql config to my.ip.address on the server and restarted
allowed tcp connection
allowed connection via ufw firewall to 3306 and 33060 ports
created a mysql user with all privileges granted for 'localhost', '%', and '0.0.0.0' hosts
tried sshing in as root user
tried using the root user for the mysql user
I am probably missing some things on that list as I feel like I've tried a million things already!
I even have a different server on a LAMP stack (not LEMP) that I set up a few days ago and was able to gain access to the mysql db on workbench by following the same steps, and even attempted backtracing and copying what I did on the LAMP server, but no go.
I checked to see the netstats of the mysql instance and match the port and the ip and that didn't work, I made sure the port of the SSH was correct, nothing is working.
Does anyone have any tips? I've been using all of the "allow remote mysql connection on digital ocean" articles and questions i can find but nothing is working.
Here is my Workbench connection config at the moment but i have tried what feels like every iteration of it i could think of (re users, passwords, IP addresses, and ports)
SSH Hostname: my.ip.address
SSH Username: user
SSH Password: user-password (also tried empty, since i have a key)
SSH Key File: same key file i use to ssh on terminal
Mysql Hostname: 127.0.0.1 (also tried my.ip.address)
MySql Server Port: 3306 (also tried 33060)
Username: MySqlUser
Password: MySqlUser-Password (works when connecting to mysql via terminal)
I'm trying to connect on my mysql database when I'm not on localhost - on localhost it's working. Everytime I wish to connect, I don't have any error, but only a timeout exec...
Here is what I've done so far
create a user on mysql who can access to any hosts("%")
purge the iptables
my port 3306 is opened (see screenshot)
the bind-address line is 0.0.0.0 in the mysqld.cnf file - I even tried to put in it comment - please note my.cnf sends to the mysqld.cnf file.
of course for every modification I've restarted the mysql server - and the server itself...
no firewall are setup...
I'm on Ubuntu 16.04 LTS, mysql and phpmyadmin are setup on it.
What I'm missing ?
Thank you for your help
Bastien
After you changed the bind address you restarted with systemctl restart mysql.service, yes?
Here's a very similar situation, try following all of these steps: Remote Connections Mysql Ubuntu
I think the flush privileges step will be a help to you.
I need to access my MariaDB installation from another PC on my local network but get the following error:
ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.1.127' (111)
I know this is because it's bound to localhost but I can't seem to find the relevant config file. I have tried several but it looks like this:
/etc/mysql/mariadb.conf.d/50-server.cnf
is the only one with settings in it but after restarting I still cannot access. As a test I temporarily changed the port to 3305 from 3306 and running lsof -i -P | grep :3306 still showed mysql running on 3306 so I know the settings are not taking.
Where is the config file or am I missing something?
I just figured out what was wrong:
/etc/mysql/mariadb.conf.d/50-server.cnf
Is the correct file but for some reason
service mysql restart
Didn't take so I tried rebooting and it's fixed! Hope this helps someone..
It is impossible to connect to mysql that I setup with phpmyadmin on a debian 8 VPS. I have been searching for hours, I have even followed this guide http://www.cyberciti.biz/tips/how-do-i-enable-remote-access-to-mysql-database-server.html but nothing, it seems imposible to get to connect to it, I even have created a phpmyadmin profile that is not on localhost and on %...
Thanks a lot for helping...
111 means connection refused, so make sure your mysql config is correct, and check your firewall.
Mysql config details (from Can't connect to MySQL server error 111):
If you have lines like this :
skip-networking
bind-address = 127.0.0.1
In your my.cnf configuration file, you should comment them (add a # at the beginning of the lines), and restart MySQL.
That's the first thing to try. Then try turning off any firewall and connecting again. That will tell you whether there's a firewall problem.
I'm trying to install Concrete5 on a localhost using MAMP, but every time I put it the database information, I get this error.
SQLSTATE[HY000] [2002] No such file or directory
How can I solve this problem?
Error 2002 is typically displayed as
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/path/to/mysqld/mysqld.sock'
PHP can't connect to MySQL using a socket. On windows you probably don't want to use unix socket.
"But I'm not using unix sockets, I'm simply connecting to localhost" you might say.
For the PHP driver 'localhost' has a special meaning as described in the PHP manual.
The hostname localhost has a special meaning. It is bound to the use of Unix domain sockets. It is not possible to open a TCP/IP connection using the hostname localhost you must use 127.0.0.1 instead.
Solution: configure 127.0.0.1 as your MySQL host for Concrete5.
I finally solved this problem. I went into MAMP and found the MySQL port number and typed into the server box in this format: localhost:[MySQL Port].
Try 127.0.0.1:[MySQL port], that did the trick for me.
To find your port number, go to the MySQL section in MAMP and look at the top right corner of the screen. There will be a message saying: MySQL is configured to use port [port number].
I did it on MacOS 10.13 and MAMP 5.1, create a symlink to mysql.sock in /var/mysql (create the directory if it does not exist).
It's solution works global, without change any config, so PHP can connect to MySQL.
Type it in console/terminal:
sudo mkdir /var/mysql
cd /var/mysql && sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock