Mysql ERROR : not connected

I am trying to connect to MySQL database from MySQL shell on windows.

No matter what I type in MySQL shell, it keeps giving me error : 'Not connected'.

Query eg 1 : mysql --host=localhost --port=3306 --user=root -p;

Query eg 2 : mysql -u root -p

O/P : ERROR: Not connected

I have MySQL server installed on my machine. Also MySQL service is running in the background.

Also, I was able to connect from MySQL workbench.

ERROR MESSAGE

MySQL Workbench Connection

1

5 Answers

My temporary workaround is that I make use of ssl protocol to connect to MySQL server :

MySQL> \connect root@localhost

MySQL localhost:33060+ ssl SQL > show databases;

0

The first step is that you need to check if you are in the MYSQL Shell SQL mode or JS mode.

Then if you are in SQL mode then you are good to go else you need to switch to SQL mode by this command

\sql

The next step is to connect using this command

\connect root@localhost

In your case, you might have given the privilege as the IP address so you need to check your localhost IP which can be done by this command in your command prompt.

ipconfig and then just check the IP address and put it in place of localhost in the previous command. If this still doesn't works then put 127.0.0.1:3306.

After this, it will prompt to add or save the password , enter a unique password there.

After this you are good to go and check the user and localhost after this by this command

SELECT user, host FROM mysql.user;

1

Try mysql -u root -pI haven't used MySQL shell, I typically use gitbash and it works just fine

2

I had faced the same issue on my Windows 10 machine with MySQL 5.7 and the following commands helped me:

mysqlsh.exe - to open mysql shell; then

\sql - to start working with SQL;

finally:

\connect root@127.0.0.1:3306

You can use:

mysql -uroot -hlocalhost -P3306 -p

or

mysql -uroot -h127.0.0.1 -P3306 -p

or

mysql -uroot -p
2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like