|
|
Cry MySQL How to...Connect to a MySQL database using the mysql command line toolMySQL provides a useful command line tool called " Database on same computerTo connect to a database on the same computer: mysql -u<account> -p<password> where
So for example: mysql -uroot -psecret would connect using the account "root" and the password "secret". MySQL supports a longer and clearer way of specifying these command line parameters, so the following is equivalent to the last example: mysql --user=root --password=secret Database on different computerTo connect to a database on a different computer: mysql -u<account> -p<password> -h<computer> where
So, for example: mysql -uroot -psecret -hcompb would connect using the account "root", the password "secret" to the MySQL database running on the computer called "compb". MySQL supports a longer and clearer way of specifying these command line parameters, so the following is equivalent to the last example: mysql --user=root --password=secret --host=compb Specifying which databaseTo specify which database to connect to, use: mysql ... -d<database> or mysql ... -=database=<database> so for example: mysql --user=root --password=secret --database=census would connect to the database called "census" on the local computer, using the account "root" and the password "secret". General Notes
These notes have been tested against MySQL version 4 |