Home > Database > Mysql Tutorial > How Do I Connect to MySQL from the Mac Command Line?

How Do I Connect to MySQL from the Mac Command Line?

Patricia Arquette
Release: 2024-11-26 00:51:15
Original
1052 people have browsed it

How Do I Connect to MySQL from the Mac Command Line?

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 
Copy after login

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
Copy after login
  • 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!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template