Connecting to MySQL from the Mac Command Line
When following PHP/SQL tutorials, the assumption is often made that you're already connected to MySQL. Here's how to initiate this connection from the Mac command line:
mysql -u USERNAME -pPASSWORD -h HOSTNAMEORIP DATABASENAME
Option Breakdown:
- -u: Specifies the username
- -p: Prompts for the password (avoid any space between -p and the password)
- -h: Indicates the host
- DATABASENAME: The database to connect to
Additional Tips:
- If desired, you can omit the password from the command and be prompted for it separately:
mysql -u USERNAME -h HOSTNAMEORIP DATABASENAME -p
- Access the MySQL reference documentation for further details and options:
https://dev.mysql.com/doc/refman/5.0/en/connecting.html
The above is the detailed content of How Do I Connect to MySQL from the Mac Command Line?. For more information, please follow other related articles on the PHP Chinese website!
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn