Access mysql remote database from command line Access mysql remote database from command line mysql mysql

Access mysql remote database from command line


To directly login to a remote mysql console, use the below command:

mysql -u {username} -p'{password}' \    -h {remote server ip or name} -P {port} \    -D {DB name}

For example

mysql -u root -p'root' \        -h 127.0.0.1 -P 3306 \        -D local

no space after -p as specified in the documentation

It will take you to the mysql console directly by switching to the mentioned database.


simply put this on terminal at ubuntu:

mysql -u username -h host -p

Now hit enter

terminal will ask you password, enter the password and you are into database server


edit my.cnf file:

vi /etc/my.cnf:

make sure that:

bind-address=YOUR-SERVER-IP

and if you have the line:

skip-networking

make sure to comment it:

#skip-networking

don't forget to restart:

/etc/init.d/mysqld restart