I am using laravel 5.4 and on remote server ubuntu 16.04 with latest mariaDB,
I made almost all the configuration listed in google and also i revert to the original state.
My current problem is that i cannot connect to my remote mariadb. Credentials are absolutely fine.
I changed the /etc/mysql/mariadb.conf.d/50-server.cnf file for the bind-address where i gave the ip of the server, The ip where i can access my phpmyadmin like 1.1.1.1/phpmyadmin. Current .env setting is :
DB_CONNECTION=mysql
DB_HOST=1.1.1.1
DB_PORT=3306
DB_DATABASE=*******
DB_USERNAME=root
DB_PASSWORD=********
But the error it throws SQLSTATE[HY000] [2002] No connection could be made because the target machine actively refused it..
Check your AppArmor profiles. It may be blocking the mysqld process from accessing network.
$ sudo apparmor_status
Make sure mysqld is not in any "enforce" mode.
Check to see if there is a mysqld profile in /etc/apparmor.d/
$ ls /etc/apparmor.d/*mysqld*
To disable it, put a simlink in /etc/apparmor.d/disable/
$ sudo ln -s /etc/apparmor.d/<full_name_of_mysqld_file> /etc/apparmor.d/disable/
followed by
$ sudo apparmor_parser -R /etc/apparmor.d/<full_name_of_mysqld_file>
Verify that mysqld protection is disabled:
$ sudo aa-status
Related
I followed the instructions to install Valet and it worked fine the first 2 days with no problems at all. Then out of nowhere it stopped working and only seemed to get worse with time. First there were 404 errors on all laravel projects beyond their homepage and eventually the sites stopped working altogether as if there isn't a web server running.
Here are some details about my environment:
Running macOS Sierra, PHP 7.1, MariaDB
Composer works fine and is in path
Valet 2.0.3 (latest at the time of writing this)
Changed MAMP to default ports to free up ports 80 and 3306 before installing and running Valet the first time
Pinging something.dev returns 127.0.0.1 as it should
Running something.dev in browser does not work D if there is no web server running
After hours of searching, fiddling, uninstalling and reinstalling everything I am now at a very bizarre point. If MAMP is running on ports 80 and 3306 Valet will serve something.dev although I still get 404 beyond the homepage. How can this be? Isn't MAMP supposed to be on other ports to free up 80 and 3306 for Valet or not running at all? The other strange thing is that something.dev will return my webroot which is Valet parked and not the site something.dev which is under the webroot.
I have searched high and low and I am at a loss as to how I can get things running the way they should be
Follow this steps to solve it:
You have to troubleshoot your nginx installation/configuration, as this is the server behind Valet.
I've got through "valet not serving" issue with the first restart that came after valet installation.
1st check you're using the latest version
$ brew update
$ brew upgrade (if you're using brew)
2nd Test configuration of nginx, there could be some permission issues:
$ nginx -t - this return the "error" paths that can't be read. For eg. will return the path to your valet error.log or conf file. eg:
2017/02/04 16:32:31 [emerg] 17285#0: open() "/Users/username/.valet/Log/nginx-error.log" failed (13: Permission denied)
Checking the file: $ ls -l ~/.valet/Log/nginx-error.log
-rw-r--r-- 1 root staff 7842 Feb 4 15:54 ~/.valet/Log/nginx-error.log
The reason why my nginx wasn't started to serve all the valet sites was that in my home directory the error log was owned by the root. Change permissions as fitted for this file and maybe others, using chown command (replace with actual username):
$ sudo chown username:staff ~/.valet/Log/nginx-error.log
after changing permissions, restart nginx:
$ sudo nginx -s stop && sudo nginx
If the command will return
nginx: [error] invalid PID number "" in "/usr/local/var/run/nginx.pid", thats because nginx is not running and have no PID, just start nginx again using:
$ sudo nginx
Now test your valet sites. (while MAMP is stopped)
Next. Decide upon ports and configure Valet and MAMP to work without conflicts.
Hope this helped.
Note: The user:group that must own your error log file can be found in nginx.conf at the user directive.
I have to make Laravel app and to deliver a Dockerfile, but I'm really stuck with this. Before that I had a nightmare wile installing laravel on my machine.
I'm trying to get dockervel image and following the steps here:
http://www.spiralout.eu/2015/12/dockervel-laravel-development.html
But when I run dartisan make:auth it gives this error below:
**ERROR:** for dockervel_mysql_1 **Cannot restart container** c258b418c03cbd6ec02c349c12cf09403f0eaf42fa9248019af7860d037d6474: **driver failed programming external connectivity on endpoint dockervel_mysql_1** (da3dd576458aa1fe3af7b539c48b9d61d97432cf5e9ee02d78562851f53981ae): E**rror starting userland proxy: listen tcp0.0.0.0:3306: bind: address already in use.**
I have tried to Change the default port in the docker-compose.yml
ports:
- "8084:80"
Still nothing, also tried to stop apache2 (service apache2 stop) on my machine ,also tried docker-compose restart and removing docker container dockervel_mysql_1.
I have to mention that I have already one Laravel proj. in /var/www/laravel.
Please help!
I had the same problem and
sudo netstat -nlpt |grep 3306
showed me the PID and which service it was started by (mysgld). Whenever I tried to kill the PID then it was started again. But the problem was fixed when I stopped the service by
sudo service mysql stop
Notice that you will have to use mysql and not mysqld.
I hope that this will do it for you - I was able to run docker-compose up without any problems
Try to kill all the processes using the port 3306:
sudo kill `sudo lsof -t -i:3306`
Then, run your docker containers:
sudo docker-compose up
Probably you have already a MySQL service running in port 3306. You should close it first.
Then try to end docker-compose down and restart it with docker-compose up.
Remember also to change the permissions after you add a file in your project (like dartisan make:auth) with dpermit
UPDATE:
since you have changed the port to "8084" you should go to localhost:8084
If you see the apache default then you probably are browsing another server since dockervel is build upon nginx.
You have also probably have some gaps on Docker. Don't mix your local storage with docker storage. /var/www in a container is different than your local /var/www. in docker-compose.yml you mount the local ~/dockervel/www to containers /var/www.
I would suggest that you start all over again and revert the changes you've made to your apache server. Shut it down, you don't need it. Dockervel will provide you with an NginX server in a container.
My fix for this issue was to go into
docker-compose.yml
and change
ports: -3306:3306 to ports: -3307:3306
then run this command again:
docker-compose up
On Ubuntu, running this command will stop your mysql from running for your docker container to work:
sudo service mysql stop
Then, if your apache2 is running, you need to stop the service especially when you want to work with nginx:
sudo service apache2 stop
Then, you can run your docker-compose up -d ... command
So for me when I was trying to load and run MySQL image in docker container, I was getting the same error:
And even after stopping local mysql server in system preferences didn't help:
Cause the port 3306 was used by my tomcat server, so basically you have to make sure the port (in this case 3306) that the docker command wants to use should not be in use by any other service otherwise the command will fail
First Solution :
sudo service mysql stop
and then run
docker-compose up
to start the application , It is an quick and fast solution to run this mysql stop command to stop the current MySQL service on port 3306 port so the same port can be available for your docker application.
Scenario 1 : Problem will come when you want to run both application one which was running previously and next you want to run now at this time it won't work.
Second Solution to Scenario 1:
If your next/current application coming from docker then try below it will work without disturbing first application mysql service of 3306 port
Open and changed the MySQL port from docker-compose.yml file
Default configuration
ports:
- ${SERVER_PORT_DB:-3306}:3306
changed port
ports:
- ${SERVER_PORT_DB:-3307}:3306
and now run below command to start the application
docker-composer up
The error you are seeing is from a local mysql instance listening on port 3306 (currently on pid 1370 from your comments). You won't be able to run a container that publishes on this host port while it's already in use by another process. Solutions are to either stop mysql on the local host, or to change/remove the published port in your container. If the port is only needed by other containers, you can leave it unpublished and they can communicate directly on the docker private network (by default, this is "bridge").
This option did it for me:
sudo pkill mysql
You need to change the mysql port
because you are installing mysql on your machine and it takes the default port 3306
and now you are trying to make dockervel_mysql_1 run to the same port 3306 , this is why you see in the error "Address already in use"
so if you change dockervel_mysql_1 port to 3307 for example it will works fine , without stopping the mysql that is running on you machine
Running this command fixed the issue for me:
docker swarm leave --force
Explanation:
I had started docker swarm service as a master node in my localhost.
Swarm was taking network priority and making use of this ports already
If tomcat is running on your machine which is connected to MySQL 3306 port then check by killing the tomcat first and then trying to do docker-compose up.
I used two different versions of MySQL, MySQL 5 on my local machine and 8 on docker. So when your connected to mysql5 on 3306 in tomcat and if you just stop the mysql5, then the process isn't completed yet since tomcat is still connected to 3306. Kill the tomcat and then up the docker it should work.
Happy coding!!
I know this question has been quite old but someone still looking for answers. You don't have to run any kill command instead you can use docker --remove-orphans flag and it will clean it up for you. For example
docker-compose up -d --build --remove-orphans
This worked for me, just changed the app's port to 8084:80, like described here.
First, MYSQL services is running in XAMPP
and, YES, I changed the port since it conflicts with other applications
Now, the question is why can't i connect to MYSQL?
Error 2003: Cant connect to MYSQL server on 'localhost'
I also dont have any mysql services installed.
Please help. Thank you for those people who would answer me :)
First,make sure mysqld is running.
ps -ef |grep mysql
Second,get the socket file in the output of last command:
for example:--socket=/opt/lampp/var/mysql/mysql.sock
Then,try to connect to mysql:
mysql -uroot -p -P<port> -hlocalhost -S /opt/lampp/var/mysql/mysql.sock
option 1.
Goto /bin/
Run mysqld (service)
close the cmd prompt
Run mysql.exe (make sure you add the location path to PATH environment Variable)
Option 2.
try to follow this thread and see if it can help!!
http://forums.devshed.com/mysql-help-4/error-2003-cant-connect-mysql-server-localhost-10061-a-26423.html
Run mysql.exe (make sure you add the location path to PATH environment Variable)
I would to know where is PATH enviroment variable
I'm working on the symfony tutorial jobeet and I have problems to get a database connection to the MySQL-database via doctrine. Development enviroment: Mac OS X and XAMPP.
The command php symfony doctrine:build-schema gives me the following error message:
Warning: PDO::__construct(): [2002] No such file or directory (trying to connect via unix:///var/mysql/mysql.sock) in /Users/xx/projects/myproject/lib/vendor/symfony/lib/plugins/sfDoctrinePlugin/lib/vendor/doctrine/Doctrine/Connection.php on line 470
PDO Connection Error: SQLSTATE[HY000] [2002] No such file or directory
The database settings in the database.yml:
all:
doctrine:
class: sfDoctrineDatabase
param:
dsn: 'mysql:host=localhost;dbname=my_project_db'
username: root
password: root
MySQl is running. Username and password are correct. The database 'my_project_db' exists.
Could anybody give me a hint what's going wrong?
Try to create a symlink in /var/mysql to your mysql.sock:
sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql /var/mysql
Or with MAMP
cd /var; sudo ln -s /Applications/MAMP/tmp/mysql mysql
On Mac OSX Lion:
cd /var;
sudo mkdir mysql; cd mysql;
sudo ln -s /Applications/MAMP/tmp/mysql/mysql.sock mysql.sock
I had the same problem on my apple mac and did the following:
cd /var; sudo ln -s /Applications/XAMPP/xamppfiles/var/mysql/ mysql
Worked for me.
This situation also happened to me and I use MAMP Pro. If you use MAMP Pro, its worth checking the main window. Look at "MySQL" tab, and then see "Allow local access only" checkbox. If it is checked, you should uncheck it. Finally, click, "Apply" button.
I'm working with an OS X 10.6 Server running Apache2 / PHP5 and having a problem with PHP not resolving hostnames when 'fopen()' tries to retrieve a file from a remote server. When run in interactive mode on the command line 'fopen()' works perfectly. However, when run through the web it will always fail with the error:
failed to open stream: php_network_getaddresses: getaddrinfo failed: nodename nor servname provided, or not known
I'm at a loss in finding the source of this problem: 'fopen()' works on the web when given an IP address instead of a hostname; 'gethostbyname()' also fails when run on the web (it doesn't error, it just returns whatever hostname it was given to resolve) but also works fine when run in interactive mode. The only exception seems to be 'dns_get_record()' which works fine when run on the web or in interactive mode.
I've been trying to find DNS problems on the server but dig, nslookup, and ping all work and "scutil -r" says the remote server is reachable with the current DNS settings. Any ideas on where the problem might be?
Try to recompile PHP with '--disable-ipv6' option. Then, apachectl stop & start (not 'apachectl restart'). I've got the same error message on Mac OS 10.6.4 + manually compiled PHP5.3.3 + Apache2.2.16.
You must set properly the allow_url_fopen value of your php.ini.
http://ar.php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen
Consider the CLI uses a different php.ini that the webserver (I assume you are using Apache).
Another option may be you are not including libnss_dns
Try adding to your httpd configuration (correct path as needed for you system):
LoadFile /lib/libnss_dns.so
If you are are running PHP-FPM with chroot settings (as you should be) - then neither DNS nor mail will work.
Update Feb 2016
strace using gethostbyname only from the test-script # https://knzl.de/setting-up-a-chroot-for-php/ solved dns for me in an Alpine Linux / nginx chroot. I also use the sh from this link with mini-sendmail to solve the mail problem.
An approximate list of files needed for DNS & Mail in a chroot
The following commands got DNS working for me with PHP5.5 on Debian (tested with the Joomla builtin update component):
#!/bin/sh
chroot=/var/www
domain=mydomain
webuser=www-data
webgroup=www-data
cd $chroot/$domain
mkdir etc
cp /etc/resolv.conf etc/
cp /etc/nsswitch.conf etc/
echo $(cat /etc/group|grep $webgroup) > etc/group
echo $(cat /etc/passwd|grep $webuser) > etc/passwd
cp /etc/services etc/
cp /etc/protocols etc/
cp /etc/host.conf etc/
cp /etc/hosts etc/
cp /etc/networks etc/
mkdir -p usr/bin
mkdir usr/sbin
cp /usr/sbin/ssmtp usr/sbin/
cp /usr/sbin/sendmail usr/sbin/
mkdir usr/share
cp -rf /usr/share/zoneinfo usr/share
mkdir lib
cp /lib/i386-linux-gnu/libresolv.so.2 lib/
cp /lib/i386-linux-gnu/libnss_compat.so.2 lib/
cp /lib/i386-linux-gnu/libc.so.6 lib/
cp /lib/i386-linux-gnu/libnsl.so.1 lib/
cp /lib/i386-linux-gnu/libnss_files.so.2 lib/
cp /lib/i386-linux-gnu/libz.so.1 lib/
cp /lib/i386-linux-gnu/libdl.so.2 lib/
cp /lib/i386-linux-gnu/libcidn.so.1 lib/
cp /lib/i386-linux-gnu/ld-linux.so.2 lib/
cp /lib/i386-linux-gnu/libcrypt.so.1 lib/
cp /lib/i386-linux-gnu/libnss_nis.so.2 lib/
cp /lib/i386-linux-gnu/libnss_dns.so.2 lib/
chown -R $webuser:$webgroup lib usr etc
service php5-fpm restart
I did not need /bin/sh or /usr/lib/locale
Same problem, different solution then the original poster. I was calling mysqli(...) to connect, but the URL I had for the server was wrong. So it doesn't always mean you are unable to do any DNS lookup, just that the server that it is not able to do that specific lookup (check your host!)
What is the hostname you tried to resolve? I had the same problem with localhost.
This didn't worked and I got your Error. I changed the hostname to 127.0.0.1 than it worked. Not the best solution, but good for a workaround.
Disable IPv6 in your TCP/IP configuration in net preference.