I have 2 mysqld.exe, one from phpMyAdmin and one from MySQL server. I use the command line command "mysql -u root -p" to connect, how do i get this command to connect to MySQL server (port 3307) by default, instead of phpMyAdmin (port 3306). It is fine to add "-P 3307", but I only want to use the command "mysql -u root -p". This command("mysql -u root -p") used to connect to port 3307, i don't know what made it change.
How can i connect to port 3307 by default.
Edit my.cnf and add port 3307 (or the one you want to be defaulted), then restart the service and you should be good.
on my.cnf be sure to have this:
port=3307
to find my.cnf file in linux or windows bash use:
sudo find / -name "my.cnf"
Related
I'm trying to make a MySQL database on my Raspberry Pi 4, but it isn't going very well, using localhost instead works perfectly but I want to remote control it from my Windows 10 computer on the same internet. When I create a user with the address of 192.168.1.15 by doing this:
sudo mysql -u root
CREATE USER 'lasse'#'192.168.1.15' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'lasse'#'192.168.1.15';
FLUSH PRIVILEGES
exit
I try to login again using this:
mysql -u lasse -h 192.168.1.15 -ppassword // didnt work, error: ERROR 2002 (HY000): Can't connect to MySQL server on '192.168.1.15' (115)
mysql -u user -h 192.168.1.2 -P 3306 -ppassword // didnt work either, same error.
I have these packages installed:
mariadb-client
mariadb-server
default-mysql-server
In the file /etc/mysql/mariadb.conf.d/50-server.cnf (Raspi-os 2021-03-04 with MariaDB installed), you should replace the line "bind-address = 127.0.0.1" (localhost) by "bind-address = 0.0.0.0" (all). After, you should restart your MySQL server : $ sudo service mariadb restart
Error 115 is returned from socket operation (EINPROGRESS), which means that your client can't physically connect to the specified server and port.
The MariaDB database server is not configured correctly, since it doesn't accept remote connections. Please login locally and check the following variables:
SHOW VARIABLES LIKE 'skip_networking' (result should be off)
SHOW VARIABLES LIKE 'bind-address' (should not be 127.0.0.1)
Since these are read only variables, you need to change them (or comment them out with a #) in your my.cnf configuration file.
ERROR 2002 is "Can't connect" error. Check out /etc/my.cnf, look for listen line. It may be listening localhost or 127.0.0.1. You need to change it to listen 0.0.0.0.
There are three things
You need to set the bind-address to 0.0.0.0 (or 192.168.1.15 to be exact and specific)
You might need to set the firewall to allow port 3306 ( or iptables --flush as shortcut )
You need to create a global user (root#'%') in the mysql database or some user like 'root#192.168.1.15' with a password
when all conditions are fulfilled, you should be able to connect to mysql database on 192.168.1.15
What is most likely the case is that the server is not listening on port 3306. As in both lines you implicit or explicit use port 3306. As it is the only constant in the two lines most likely the culprit.
The default port for clients is specified in my.ini in the [client] section, the port used by the server is in the [mysqld] section. They don't necessarily have be the same so check both.
To make absolutely sure what is going on the server — assuming it is linux — use this to list all listening ports:
sudo netstat -tnlp
There, saved you a walk to the docs.
Login to the MariaDb server and edit the file /etc/mysql/my.cnf
Edit the row bind-address=YOUR_SERVER_IP
Restart the server using '/etc/init.d/mariadb restart' or 'systemctl restart mariadb.service'
I have installed MariaDB 10.5.5 in Ubuntu 20.04 server. Right now I try to change the default port of the database to let say 12345. When I look into /etc/mysql/my.cnf and /etc/mysql/mariadb.conf.d/50-server.conf there is no port options, then I add port = 5505 inside /etc/mysql/mariadb.conf.d/50-server.conf under [mysqld], then I restart the mariadb-server using sudo systemctl restart mysql & sudo systemctl restart mariadb. But when I connect the mariadb server using mysql -uusername -p, it's just connected. The expected behavior is mysql client will reject the connection. I also try to use mysql -uusername -p -P123222, but still connected. My questions is how can I can change the port and prevent this strange behavior to happen?
Unless you don't specify a hostname, the default hostname "localhost" will be assumed, so the connection will be established via unix_socket and not via TCP/IP.
To connect via port use e.g.
mysql -h127.0.0.1 -P12345 -uusername -p
There are 2 places, at least, where you may find the
port = 3306
Make sure you are changing them all, but specifically the one under the section [mysqld]
[mysqld]
port = 3307
It is this one that tells the deamon which port to use.
My guess is you changed the one under [client]
So change both :)
The followings are commands which I have executed on Ubuntu.
$ mysql -u root -p
mysql>GRANT ALL ON my_database.* TO user#'MY_REAL_IP' IDENTIFIED BY 'passwd';
$ sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
#bind-address = 127.0.0.1
$ sudo ufw enable
$ sudo ufw allow 3306
$ service mysql restart
But when I use another computer on Ubuntu to access mysql on MY_REAL_IP type:
$ mysql -u user -p -h MY_REAL_IP
Can't connect to MySQL server on 'MY_REAL_IP'
how to fix it? thx
I guess bind-address should be 0.0.0.0. If you would like to access this server with real IP address. Or, you can access MySQL with simply localhost.
Would you please change bind-address = 0.0.0.0, and restart MySQL ?
EDIT
It looks there is no network connectivity. Please find the way to connect server with port 3306. How to make sure that firewall is off?
You may misunderstand the grand command, user#host means the user can login from host, which in your case, should be another computer's ip, or just use * for all ips
Exact path on Ubuntu 16.04
/etc/mysql/mysql.conf.d/my.cnf
bind-address = 0.0.0.0
service mysql restart
When i access MySql from mysql bin folder command prompt then its working fine. but when go with cmd to access localhost:8080 then its not working properly. I use this command for it:
C:\wamp\bin\mysql\mysql5.6.12\bin> mysql -u root -p -h localhost:8080
Is mysql really listening on port 8080? Shouldn't it be 3306?
Take a look into my.ini and check the definition in the [mysqld] section:
[mysqld]
; ...
port = 3306
; ...
you need to change MySQL default port 3306 to 8080.Find the find MySQL configuration file, in general "my.ini" than edit the line:
[mysqld]
port = 3306
to
[mysqld]
port = 8080
Then restart MySQL service, it's done.
I've got mysql 5.1 on a windows xp machine. It's listening on port 3308. I'm trying to use mysqldump:
> mysqldump -u root -pmypassword dbname > out.sql
Getting an error:
mysqldump: Got error: 2003: Can't connect to MySQL server on 'localhost' (10061) when trying to connect
Not sure what the problem is, looking at --help dumps variables and shows port=3308 as I set in the mysql installation (instead of default 3306). I don't think there's anything different with my installation. I also tried explicitly setting the port # on the command line but still same error.
Thanks
To connect through a port (and not the default 3306), use:
mysqldump -u root -pmypassword -P 3308 dbname > out.sql
Besides that, a simple test to see if MySQL responds at port 3308 is to try telneting:
telnet 127.0.0.1 3308
If MySQL is listening on port 3308, it'll respond with an error and the version running.
Go to run type services.msc
then
locate mysql service and start it .this solved
If your Mysql-Client is 5.5.16 please upgrade it to 5.6.10, this process worked for me if your mysql server is 5.6.10.