O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Connecting to the MySQL client can be done with any of the following commands:

shell> mysql -h localhost -P 3306 -u <username> -p<password>
shell> mysql --host=localhost --port=3306 --user=root --password=<password>
shell> mysql --host localhost --port 3306 --user root --password=<password>

It is highly recommended not to give the password in the command line, instead you can leave the field blank; you will be prompted for a password:

shell> mysql --host=localhost --port=3306 --user=root --password  Enter Password:
  1. The -P argument (in uppercase) is passed for specifying the port.
  2. The -p argument (in lowercase) is passed for specifying the password.
  3. There is no space after the -p argument.
  4. For the password, there is ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required