mysql -u root -p 解释
使用此命令首先确保你的mysql运行环境已经搭建好
这是客户端连接mysql服务器的指令,比较全的写法是下面两种
第一个是全拼,第二个是第一个的缩写
mysql --host=localhost --user=myname --password=password mydb
mysql -h localhost -u myname -ppassword mydb
一般在使用中,我们会省略-h参数,mysql会自动默认为本地连接
还有一点就是各个参数之间是否有空格的问题,-u后面可以有也可以省略空格,对于-p后面的参数我要单独说一下
这是我从mysql官方文档拷过来的内容
for password options, the password value is optional:
If you use a -p or --password option and specify the password value, there must be no space between -p or --password= and the password following it.
If you use a -p or --password option but do not specify the password value, the client program prompts you to enter the password. The password is not displayed as you enter it. This is more secure than giving the password on the command line. Other users on your system may be able to see a password specified on the command line by executing a command such as ps auxw.
具体就是:对于password选项,此选项是可选的
如果你明确指定了-p或者--password的值,那么-p或者--password和密码值之间是不能有空格的。
如果你使用了-p或者--password选项但是没有给出password值,客户端程序提示您输入密码。
For mysql, the first nonoption argument is taken as the name of the default database. If there is no such option, mysql does not select a default database.
对于MySQL,第一个非选项参数被当作默认数据库的名称。如果没有这样的选项,MySQL就不会选择默认数据库。
也就是说在命令行中,你的mysql密码和-p或者--password参数之间有空格,mysql会认为你输入的是登录mysql后自动选择的数据库,而不是你所期望的密码
当然命令行连接数据库还有其它参数,这里主要介绍几个经常使用的,其它请参考https://dev.mysql.com/doc/refman/5.5/en/connecting.html
mysql -u root -p 解释的更多相关文章
- windows下的mysql忘记root密码的解决方法
1.首先,需要关闭MySQL Server服务.在"运行"窗口,输入"services.msc",进入"服务"窗口. 2. 在服务窗口,可以 ...
- linux下误删mysql的root用户,解决方法
开始对liunx界面不熟悉,可能由于不小心,把root误删了,怎么办? 1. # killall mysqld 干掉所有mysql进程 2. # mysqld_safe --skip-grant ...
- mysql忘记root密码怎么办?
有时候忘记mysql的root密码了,怎么办? 这个时候,我们可以修改my.cnf,添加以不检查权限的方式启动,再修改root,最后重启mysql数据库. (1)service mysql stop ...
- MySQL修改root密码的多种方法
不知道在cmd模式下是不是区分大小写,我大写成功了,小写没成功,不知是我拼写的错误,还是区分大小写!!?? 方法1: 用SET PASSWORD命令 mysql -u root mysql> S ...
- Mysql修改root密码
一.启动命令行,输入: taskkill /f /im mysqld.exe //关闭mysql 二.转入mysql的bin目录下 三.输入:mysqld --skip-grant-tables // ...
- windows下新安装的mysql修改root password问题
常用步骤: 1. 在my.ini中的mysqld下添加一行 skip-grant-tables 2.重启mysql后直接进入后,用SQL直接修改password列: C:\> net stop ...
- 忘记Mysql的root密码怎么办?
有时候忘掉了mysql的root密码,这种情况下,如何重置root的密码呢? 找到并编辑mysql的my.ini配置文件,在mysqld节点中添加上skip-grant-table. 如下: [mys ...
- MySQL修改root账号密码
MySQL数据库中如何修改root用户的密码呢?下面总结了修改root用户密码的一些方法 1: 使用set password语句修改 mysql> select user(); +----- ...
- mac 安装mysql + 修改root用户密码 + 及报Access denied for user 'root'@'localhost' (using password:YES)解决办法
1.下载MySQL 到mysql的官网http://dev.mysql.com/downloads/mysql/然后在页面中会看到“MySQL Community Server”下方有一个“downl ...
随机推荐
- CodeForces - 186A-Comparing Strings
Some dwarves that are finishing the StUDY (State University for Dwarven Youngsters) Bachelor courses ...
- linux查看硬盘空间,删除大文件
df -Phdu -h --max-depth=1du -sh /u02/weblogic/user_projects/domains/logsdu -sh /u02/mysqlfind / -siz ...
- 牛客网训练赛26D(xor)
题目链接:https://www.nowcoder.com/acm/contest/180/D 线性基的学习:https://www.cnblogs.com/vb4896/p/6149022.html ...
- python操作json文件
import json class OperationJson(object): def __init__(self,file_name=None): if file_name: self.file_ ...
- AOP的XML实现方式
与注解方式类似,只不过所有设置是通过xml来设置 // 切面类 public class Aop { public void around(ProceedingJoinPoint pjp) throw ...
- strstr strcpy 函数的实现
一. strcpy 代码实现 #include <iostream> #include <assert.h> #include <iostream> //#incl ...
- AngularJs在ng-click函数中如何获取代表当前元素的DOM对象
<!DOCTYPE html> <html> <head> <title></title> <script src="lib ...
- 输入网址调用第三方接口获取结果_java
最近公司给了一个第三方服务的网址,要我调用后返回需要用到的信息 具体网址:http://www.xxxx.com/xxx-api/xxxx/getXxxByUserId?userId=" + ...
- centos yum 安装mysql5.7 以及 默认root密码查看
1. 首先更新rpm 从MySQL Yum仓库下载最新的rpm文件:http://dev.mysql.com/downloads/repo/yum/ (需要Oracle帐号以及填写一些使用信息,才能 ...
- Servlet高级部分Filter(过滤器)
一:Filter称之为"过滤器",用在Servlet外,对request和response进行修改.它是AOP(面向切面编程思想的一种体现),Filter中有一个FilterCha ...