how to use lampp with external mysql - mysql

I have installed normal mysql with apt-get and now I need to connect it with my lampp server, when is lampp booting it echo "Another MySQL deamon already running" (of course - thats right), but when I open phpmyadmin it gives me an message
2002 - The server is not responding (or the local MySQL server's socket is not correctly configured)
So how I could connect non-lampp mysql with lampp - I suppose that will be with a mysql socket, but I don't know how...

mysql listens for two seperiate types of connections, tcp and unix socket. You can view what your mysqld process listens to with the netstat command:
# netstat -npl | grep mysql
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 2059/mysqld
unix 2 [ ACC ] STREAM LISTENING 6221 2059/mysqld /var/lib/mysql/mysql.sock
Default port for tcp is 3306, and default socket is /var/lib/mysql/mysql.sock (at least it is on RHEL). Local connections (such as the mysql command) tend to use the socket, while remote connections (other servers) need to use the TCP socket.
If your server isn't listening on one, you may have to specify them in your mysqld configuration. These values are controlled in the /etc/my.cnf file:
[mysqld]
socket=/var/lib/mysql/mysql.sock
port=3306
Also, if your TCP socket is listening on localhost only (127.0.0.1) you can specify this in the my.cnf file:
bind_address=0.0.0.0
0.0.0.0 means listen on all local interfaces. If you want it to listen on a specific IP address, specify it.

Related

Cannot connect to mysql server in an Amazon EC2 instance

I have a problem in connecting to my MySQL server running on an EC2 Ubuntu instance.
In the /etc/mysql/mysql.conf.d/mysqld.cnf,
I've set the port=3306
I've set thebind-address=0.0.0.0.
Commented skip-external-locking
netstat -an | grep 3306 returns
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
I allowed the connections using sudo ufw allow 3306
Still Iam getting the error as below. (I have added the db.apim.com to /etc/hosts )
ERROR 2003 (HY000): Can't connect to MySQL server on 'db.apim.com' (110)
Note : I followed everything in this blog
This is resolved by adding a suitable inbound traffic rule.
By adding Type : TCP and Source: 0.0.0.0/0 as a new inbound traffic rule this issue resolved [1].
Thanks #GobindDeepSingh for pointing this out.
[1] https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/authorizing-access-to-an-instance.html

Slave I/O: error connecting to master

I'm following this tutorial for Master-slave-replication
for my database replication and this working fine for test servers in which both servers have not ssl installed. But when I trying to do the same with my production server where only master has ssl installed not slave server, I'm getting this error Slave I/O: error connecting to master 'server-ipaddress:3306' - retry-time: 60 retries: 86400, Error_code: 2003. Is this problem of ssl connection or something else.
Also when setting up mysql configuration on master server after taking dump file of database and unlocking tables my mysql server shut down with my website showing this error error establishing database connection after restarting mysql my website working fine again.
My master server is running on nginx server with wordpress installed and I have also checked that 3306 is listening on my master server.
Why my slave unable to connect to my master server, any solution?
You can use command below to check the ip address mysql server is listening
netstat -nlt | grep 3306
sample result:
tcp 0 0 xxx.xxx.xxx.xxx:3306 0.0.0.0:* LISTEN
If the result showing same result like me then add a replication master user to access the server database.
If netfilter firewall is enabled (sudo ufw enable) on mysql server machine, do the following to open port 3306 for remote access:
sudo ufw allow 3306
check status again :
sudo ufw status
You will see your tcp port for 3306 is open for connection from anywhere. Now you try to connect from slave server you will get the result.
i solved like this:
sudo iptables -I INPUT 1 -p tcp -s ipmaster --dport 3306 -j ACCEPT
sudo iptables -I INPUT 2 -p tcp --dport 3306 -j DROP

Database Not connectable through Public IP

NOTE. operation system is ubuntu 14.*
I am breaking my head over my connection on my MYSQL server. I try to connect to my MYSQL server internal through my public ip. But i am unable to connect. While i am able to connect when i connect to localhost and when i connect externally.
# Instead of skip-networking the default is now to listen only on
# localhost which is more compatible and is not less secure.
#bind-address = 127.0.0.1
I commented the bind-adress out and this should bind the addres to 0.0.0.0. I also tried to setup the bind-adres to 0.0.0.0. This also doesnt work.
My hosts file is setup up as follows:
127.0.0.1 MY-IP
When i telnet on port 80 to my public ip there is no problem.
telnet MY-IP 80
I get:
Trying MY-IP...
Connected to MY-IP.
Escape character is '^]'.
But when i try this on port 3306 it keeps on:
Trying MY-IP...
I also granted all the right permissions to my MYSQL users. And i am possible to connect externaly and internaly. But it is not possible for me to connect internaly with my public ip.
Also i tried to find a solution with netstat.
netstat -tln
give mes
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
EDIT: Just disabled UFW. It still doesnt work.
ufw status
Status: inactive
EDIT2: Is it possible that mysql is ignoring the /etc/hosts file?
Could somebody help me a bit further with some great ideas where the problem might be.
You should change the bind address to 0.0.0.0 then restart the mysqld. Also make sure there is no firewall enabled:
iptables -n -L
if there are rules, blocking port 3306, delete them, or just disable the firwall with
iptables -F
also use netstat to check if the server is listening on the external ip:
netstat -tupan |grep :3306

Connecting to MySQL from Workbench

MySQL remote access
I have a mysql database, running on Ubuntu Server 12.04 that I need to access remotely. For some reason this is become much more of a chore than I think it should be.
I have been through countless threads trying to resolve this issue with no luck what so ever. I do not have another linux box to test my connection. I am only using the MySQL Workbench from a Window 7 machine.
Here is what I have done so far:
set the iptables to accept
set the my.cnf to have the bind address of the server
created a user for both localhost and %
grant all to those users
restarted mysql
verified the user has all priv
verified mysql is listening on 3306
give the correct setting to Workbench and I get
"Your connection attempt failed for user 'USER' from your host to server at x.x.x.x:3306:
Can't connect to MySQL server on 'x.x.x.x' (10061)"
EDIT: I did notice that it show 'localhost and NOT the ipaddress when I run this cmd, but i'm not sure how to change that, or if it is even the issue. Thoughts?
# lsof -i -P | grep :3306
mysqld 5775 mysql 10u IPv4 154265 0t0 TCP localhost:3306 (LISTEN)
vim /etc/mysql/my.cnf
Change the following line to reflect as below:
(bind-address = 127.0.0.1)
bind-address = 0.0.0.0
Close the file then and restart mysql
To verify that mysql port 3306 is listening on all interfaces:
netstat -lnt | grep 3306
You should see this:
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
Find mysql config file (/etc/mysql/)
comment out the following line by putting a hash character in front of it as shown -> #bind-address = 127.0.0.1
-> Restart the server: sudo service mysql restart

Connect to remote mysql via terminal

For a test I set up user mysql user with % access. When I try to connect from a remote machine I get:
Enter password:
Then immediately get this:
ERROR 2003 (HY000): Can’t connect to MySQL server on ‘xxxxxxx’ (1)
Any ideas
Verify that you can connect to the mysql port with telnet from that remote machine, e.g.
telnet 192.168.1.52 3306
If that fails, there's a firewall somewhere preventing you to connect, or you're running mysql on a different port than the default(3306) or mysql isn't configured to listen on the interface/ip address (maybe it's just configured to listen on connections from localhost, check the bind-address configuration in the my.cnf config file)
Try to comment the bind-address = 127.0.0.1 in your /etc/mysql/my.cnf
# security:
# using "localhost" in connects uses sockets by default
# skip-networking
# bind-address = 127.0.0.1 --- commented
and watch the results. If not work try to use the IP address and if still not work. roll back the original file.
Can you telnet to the MySQL port 3306? If you can't then check to make sure the MySQL server service is listening on that port. Open a command prompt and type the following example.
Example: telnet yourmysqlservername.com 3306