Connect to a MySQL server using the mysql command
The mysql command provides a text-based interface into the MySQL database server. Once connected, SQL commands can be issued to the server to make queries, create or alter databases or tables, or many other operations.
To connect to the MySQL server on the local system, issue the following command:
mysql -u username -p
Enter password: *******
Where username is the name of a user authorized to use the database (see Create a MySQL user account). The -p option will prompt for the user’s password as shown below the command.
If the MySQL server resides on a remote host, the mysql command, if present on the local system, can be used to connect to the MySQL server accross the network. To connect to a MySQL server on a host named ‘elephant’ use the following command:
mysql -h elephant -u username -p
Follow the reactions below and share your own thoughts.