mysql command line connect to database code example

Example 1: mysql connect command

mysql --host=localhost --user=myname --password mydb
mysql -h localhost -u myname -p mydb

Example 2: login to database mysql terminal

mysql -u USERNAME -p

Example 3: mysql cli connect with password

mysql --user=root --password=mypass

Example 4: connect mysql command line

mysql --host=localhost --port=myport --user=myname --password
mysql -h localhost -u myname -p --port=myport

Example 5: login to database mysql terminal

use DBNAME;

Example 6: login to database mysql terminal

show databases;

Tags:

Php Example