在命令行中打开MySQL有几个简单的步骤。首先,打开你的终端并输入以下命令以登录到MySQL:
mysql -u [username] -p
请确保将[username]替换为你的MySQL用户名。然后,按Enter键并输入MySQL密码。您应该看到以下输出:
Welcome to the MySQL monitor. Commands end with ; or g.
Your MySQL connection id isServer version:Copyright (c), Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
现在,您已经成功登录到MySQL。您可以开始执行SQL查询和命令。
要退出MySQL,请在mysql>提示下键入以下命令:
exit
这将退出MySQL并返回到终端。