Apparently, I cannot connect to SQL server using the mysql.exe
I logged in as the root user and typed the following
mysql -u root -p
mysql> CONNECT TO 127.0.0.1:3306;
I receive the folling error.
ERROR 2005 (HY000): Unknown MySQL server host '127.0.01:3306' (2)
Unknown MySQL server host '127.0.0.1:3306' (2)
However it connects justs fine using MySQL Workbench with the same parameters.
Host:127.0.0.1
Port:3306
User: root
pass:[empty]
I have the easyphp MySQL module installed. Could this be the reason?
EDIT: TYPO with 127.0.0.1 sorry
Best Answer
According to the documentation, the syntax of the
connect
command is:Therefore your command
CONNECT TO 127.0.0.1:3306
is attempting to connect to a database calledTO
on a host called127.0.0.1:3306
. The error message you receive in return unsurprisingly complains that the host does not exist.However, it is more usual to specify the hostname and database on invoking
mysql
(whereupon one can also specify the port if one wishes - see this page for a full list of command line options):Also note that if the hostname and port are not specified, they default to localhost and 3309 - therefore in your case you can omit all of the above and just go with:
To do what you're currently doing (not specifying the database name on the command-line), you must call the
USE
command at themysql>
prompt to select a database after you've connected: