Tuesday, 2 February 2016

How to Connect to the MySQL ServerIn Feburary 2016 02,

In Feburary 2016 02,
Connect to a MySQL server running on localhost. The MySQL command-line client's default behavior is to connect to a server running on localhost. This will connect to the server on localhost as the root user with no password. Example:
mysql -u root
Connect to a MySQL server using a password by adding the -p switch. This will connect to localhost as root and prompt you for a password. Example:
mysql -u root -p
Connect to a remote host using the -h switch. A remote host is any server other than localhost. Using the -h switch will connect to a MySQL server running on example.com as root and prompting for a password. Example:
mysql -u root -p -h example.com
Connect to a remote host running on a non-default port, using the -P switch. Note that this command uses a capital P. It should not be confused with the lowercase -p switch, which means prompt for a password. Using the -P switch will connect, as the root user, to a MySQL server running on example.com port 3330 and prompt for a password. Example:
mysql -u root -p -h example.com -P 3330
Connect to a server and use a database. Specify the database to use on the command-line in place of connecting and manually issuing a USE command. It's faster and makes automated scripts work better. Simply add the name of the database onto the end of the MySQL client command-line. This example connects to the database as root and uses the customers database. Example:
mysql -u root -p -h example.com -P 3330 customers
In Feburary 2016 02,

No comments:

Post a Comment