Home > Database > Mysql Tutorial > mysql 命令行登录实例演示

mysql 命令行登录实例演示

WBOY
Release: 2016-06-01 09:56:48
Original
1078 people have browsed it

在登录到MySQL之前,我们必须将账号和密码传递给MySQL客户端程序。

通过以下命令和语法完成:

<code class="language-sql">c:\mysql\bin\mysql -u <mysql_username> -p <password> <database name></database></password></mysql_username></code>
Copy after login

mysql_username表示mysql数据库登录的用户名, password表示mysql数据库登录的密码,database name表示数据库名称,这里可以有可无。

如下:登录到mysql并对进入mydb数据库

<code class="language-sql">c:\mysql\bin\mysql -u root -p 123456 mydb</code>
Copy after login

如果我们忽略密码,但仍保留密码标志(-p),将会出现以下提示:

<code class="language-sql">$ mysql -u yourUserName -p yourDatabaseName
Enter password:</code>
Copy after login

你也可以省略数据库的名称。

<code class="language-sql">$ mysql -u yourUserName -p
Enter password:</code>
Copy after login

如果你的用户拥有不同的数据库权限,你可以选择特定的数据库:

<code class="language-sql">mysql> use yourDatabaseName
Database changed</code>
Copy after login

Related labels:
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template