How can i connect to mysql using terminal? - mysql

I'm trying to connect to the mysql server on my mac using terminal. I've already got MAMP on my mac but now I have installed XAMPP. when I type this into my terminal
mysql -u root -p
it comes up with this message...
ERROR 2002 (HY000): Can't connect to local MySQL server through socket
'/Applications/MAMP/tmp/mysql/mysql.sock' (2)
I'm wondering is it because of XAMPP? Any suggestions?

have you tried
mysql -h 127.0.0.1 -u root -p
(if the mysql server isn't running on your local box, substitute the IP address of the mysql server for 127.0.0.1)

Related

Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'

I'm new to Ubuntu.
I have xampp installed on Ubuntu and works just fine. But when I am trying to run mysql -u username -p pass from terminal I recieve this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock'.
I've tried to install mysql-server again but it runs completely separate (has another database....and is not working with phpmyadmin from xampp).
How can I make it work in terminal from xampp server?
Your mysql-database might not be running at all!
Try this: sudo /etc/init.d/mysql start then mysql -u yourusername -p yourpasswrd

Connecting to a mysql running on a Docker container ubuntu 16.04

I have mysql container on docker. Mysql is running correcty now(because my application is running).
When I type docker-compose ps I see mysql is up. This is related part in pom.xml :
<driver>com.mysql.jdbc.Driver</driver>
<url>jdbc:mysql://127.0.0.1:3310/fraud_dev</url>
<defaultSchemaName>abc_dev</defaultSchemaName>
<username>abc_dev</username>
<password>abc_dev_123</password>
I am trying to connect mysql on localhost terminal. I am typing this :
mysql -u 'abc_dev'#'localhost:3310' -p
I am typing password. Then I am getting this error:
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
I dont know where I am wrong. How can I fix it?
Thanks.
You do not use the standard mysql port 3306. Because of this you have to specify the used port with
mysql -u abc_dev -p -h localhost --port 3310

Problems connecting from laptop to MariaDB running on Debian 7.9 server

I've just set up my very first Debian 7.9 server. I also installed a regular LAMP stack with MariaDB. The database is working, I've already created another user.
The problem comes up when i try to connect to my server's MariaDB from my laptop (ubuntu 14.04). I installed mariadb-client on my laptop and tried to connect via:
mysql -u myusername -p myserversadress
The error I get is:
ERROR 2003 (HY000): Can't connect to MySQL server on ... (111)
What does it mean?
mysql -u myusername -p -h myserversadress
The "host" was assumed to be localhost, and they command, if it could connect, would look for database myserversadress.

can't access mysql in zend server

Abhimanyus-MacBook-Pro:~ abhimanyuaryan$ /usr/local/zend/mysql/bin/mysql -u root
ERROR 2002 (HY000): Can't connect to local MySQL server through
socket '/usr/local/zend/mysql/tmp/mysql.sock' (2)
I was trying to use MySQL database via terminal using the above command but then this error message showed up. How to fix it?
try bellow command
mysql -u root -h localhost -p
and give the root password
or you can install phpmyadmin and use it directly form the http://localhost/phpmyadmin after installing phpmyadmin.

connect to mysql database server in Windows from Vagrant box

I installed mysql server 5.6, and I can connect to it using mysql workbench, but I'm wondering if I can connect to it from Vagrant box, and I tried the following command, but failed:
vagrant#sdi03:~$ mysql -h 127.0.0.1 --port=3366 -u root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (111)
Note that I purposely run the mysql server on port 3366 instead of 3306, because I have another mysql server running on Vagrant box on port 3306.
I'm using success connect to ip adress of my windows, it's 192.168.1.55
mysql -u konst -p -h 192.168.1.55
PS I can't connect with root, i create new mysqluser konst with admin's rights