Installed XAMPP but can't connect to MYSQL server in cmd - php

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

Related

Cannot access phpmyadmin locally

I am aware that this has been answered multiple times, I get the 1045 error, I am trying to follow https://www.ostraining.com/blog/coding/error-1045-phpmyadmin/, but get this when trying to follow the steps:
Michaels-Air:~ michaelnares$ mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Michaels-Air:~ michaelnares$ cd /tmp
Michaels-Air:tmp michaelnares$ ls
com.apple.launchd.Uoy1kKt9Ag com.apple.launchd.bRUV1JxWGF mysql.sock.lock
Michaels-Air:tmp michaelnares$
Doing sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock doesn't create the necessary file, what else can I do please?
Is it possible that your mySQL instance is not running?
To check use:
ps aux |grep mysqld
brew reinstall mysql worked, not quite sure why.

Httpd, myslqd and SELinux

Im running put of patient with SELinux and that stuff...
I have httpd and myslqd running on the same machine with CentOs 6, and both services have their configuration files in a nfs directory exported from another machine.
Everything works fine with Selinux disabled... but when I set it to enforcing, PHP scripts can not communicate with mysql service. Httpd service works fine and mysqld too, if I run "mysql -u root" I can make queries to the database perfectly, but php scripts can not.
I think I'm missing some sebool that allows php to use mysql or something like that, but i can not find the key... some help?
You can set the following flag to allow Apache to connect to a database.
setsebool -P httpd_can_network_connect_db on
The -P option makes the change persist across reboots. You may need sudo to execute this command.

Error starting userland proxy: listen tcp 0.0.0.0:3306: bind: address already in use

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.

mysql is dead but subsys locked

I am using PHP-mysql on Linux (RHEL 5.0) For First Time
When I tried to connect to MySQL from my PHP Script using mysqli_connect.
It Displayed The Following Error:
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock'(2)
After googling for hour I found solution to this as stated here.
When I followed that approach and issued command:
service mysqld status
as a root user
I got : mysql is dead but subsys locked Any one know how to solve this and cause of this error ?
Also
Restarting
Starting
And Stopping of MySQL
is Giving Output as: FAILED But PHP is working fine. I've tested the phpinfo(); for Demo.
I've installed MySQL in /usr/local/mysql/bin. Can Anyone Help me in this ? Any help is appreciated.
Thanks in advance.
I had this problem with my OTRS server after I tried to update a to large package.
The solution was:
copy for safty:
cp /var/lock/subsys/mysqld /root/mysqld
than delete it
rm /var/lock/subsys/mysqld
than close all services that depends on mysql:
service httpd stop
service otrs stop
after that:
service mysqld restart
service httpd restart
service otrs restart
System is CentOS 6.x
service mysqld restart
Simply restarting the mysqld worked fro me on Centos.
tail /var/log/mysqld.log to check the error log
then do the following actions:
rm /var/lock/subsys/mysqld
chown -R mysql.mysql /var/run/mysqld
first,make sure that /etc/init.d/mysqld is running from /usr/local/mysql/bin
then,kill mysqld ,delete the lock file and restart it.
This (and all sorts of other weird errors) can also happen if you have a full disk. In my case, my /var partition had filled up. Freeing up space allowed mysqld to restart again.
First find the PID number of mysqld:
1. Use top | grep mysqld
2. kill -9 PID
Safe method, works fine with Cent OS
Rebooting the server worked for me. Please remember to start all the services once you reboot in case you haven't added 'chkconfig' for them, lets say httpd, named and mysql.
i use command kill, step by step:
use command service mysqld status for find PID mysqld
kill -9 PID
use command service mysqld status again for find PID mysqld
kill -15 PID
check again with command service mysqld status , check until the PID dead OR subsys locked
use command service mysqld start
The problem I meet in the project is because of the disk space run out.
The server that MySQL is running run out the disk space, business project's log is too large. The result is that MySQL restart failed.
It is one probability and you can have a try.
du -sh *
and
service mysqld restart

Trying to connect to mysql server for the first time and get an error messange: "mysql: command not found"

I am setting up my first data base using XAMPP. I followed the steps from
dev.mysql.com/tech-resources/articles/mysql_intro.html
but as I try to connect to mysqlserver by typing "mysql -u root" into my Terminal I get back an error message:
Phosphoros:~ Arthur$ mysql -u root
-bash: mysql: command not found
Phosphoros:~ Arthur$
I am using Mac OS X 10.7.5.
How can I connect to the server?
Arthur
Your terminal application doesn't know where to locate the mysql program.
For example, if you installed xampp in C:/xampp, you open a command prompt, cd to C:/xampp/mysql/bin and then run your command, which should work now.
Edit: Just remembered you mentioned OSX, regardless, use the same principle. In your terminal, cd to the XAMPP install subfolder which contains the mysql executable app
you have to run the command: mysql -u root in the mysql directory that exists in the /opt/lampp directory.

Categories