Linux上通过mysql命令访问MySQL数据库时常见问题汇总

1)创建登录账号

#创建用户并授权

#允许本地访问

create user 'test'@'localhost' identified by '123456';

#允许外网访问

create user 'test'@'%' identified by '123456';

#grant 权限  on 数据库.* to '用户名'@'登录主机' identified by '密码';

#原始密码为:123456 加密后的密码为:*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9

grant all privileges on *.* to 'root'@'%' identified by password '*6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9' with grant option;

#用户通过本地IP访问数据库

grant all privileges on *.* to 'test'@'localhost' identified by '123456';

#用户通过外网IP访问数据库

grant all privileges on *.* to 'test'@'%' identified by '123456';

#刷新权限

flush privileges;

#创建数据库

create database 数据库名;

#删除数据库

drop database 数据库名;

#删除表

drop table 表名;

#删除用户及权限

drop user '用户名'@'localhost';

drop user '用户名'@'%';

#刷新权限

flush privileges;

2)正常登录的命令

mysql -utest -p123456 -P3306 -h192.168.48.129

3)mysql命令找不到

[roadexam@centos7 src]$ mysqls -utest -p123456 -P3306 -h192.168.48.129

bash: mysqls: command not found

4)参数u大写ERROR 1064 (42000)...use near 'st' at line 1

[roadexam@centos7 src]$ mysql -Utest -p123456 -P3306 -h192.168.48.129

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 1064 (42000) at line 1: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'st' at line 1

5)用户名错误 ERROR 1045 (28000)...Access denied

[roadexam@centos7 src]$ mysql -utest1 -p123456 -P3306 -h192.168.48.129

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'test1'@'192.168.48.129' (using password: YES)

6)P为大写或和密码之间有空格或密码错误 ERROR 1045 (28000)...Access denied

[roadexam@centos7 src]$ mysql -utest -p 123456 -P3306 -h192.168.48.129

Enter password:

ERROR 1045 (28000): Access denied for user 'test'@'192.168.48.129' (using password: NO)

[roadexam@centos7 src]$ mysql -utest -P123456 -P3306 -h192.168.48.129

ERROR 1045 (28000): Access denied for user 'test'@'192.168.48.129' (using password: NO)

[roadexam@centos7 src]$ mysql -utest -p1234567 -P3306 -h192.168.48.129

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 1045 (28000): Access denied for user 'test'@'192.168.48.129' (using password: YES)

7)端口号不对 ERROR 2003 (HY000):Can't connect to MySQL...(111)

[roadexam@centos7 src]$ mysql -utest -p123456 -P3307 -h192.168.48.129

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.48.129' (111)

8)连接数据库的地址不对 ERROR 2003 (HY000): Can't connect to MySQL...(113)

[roadexam@centos7 src]$ mysql -u test -p123456 -P 3306 -h 192.168.48.121

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 2003 (HY000): Can't connect to MySQL server on '192.168.48.121' (113)

9)地址中包含端口号信息 ERROR 2005 (HY000): Unknown MySQL...(0)

[roadexam@centos7 src]$ mysql -u test -p123456 -P 3306 -h 192.168.48.129:3306

mysql: [Warning] Using a password on the command line interface can be insecure.

ERROR 2005 (HY000): Unknown MySQL server host '192.168.48.129:3306' (0)

Linux上通过MySQL命令访问MySQL数据库时常见问题汇总的更多相关文章

  1. Linux系统下授权MySQL账户访问指定数据库和数据库操作

    Linux系统下授权MySQL账户访问指定数据库 需求: 1.在MySQL中创建数据库mydata 2.新建MySQL账户admin密码123456 3.赋予账户admin对数据库mydata具有完全 ...

  2. MySQL命令行导出数据库

    MySQL命令行导出数据库:1,进入MySQL目录下的bin文件夹:cd MySQL中到bin文件夹的目录如我输入的命令行:cd C:\Program Files\MySQL\MySQL Server ...

  3. 文件批量加密重命名--python脚本AND mysql命令行导入数据库

    在考试中学生交上来的报告,需要进行一下文件名加密,这样阅卷老师就不知道是谁的报告了 在百度帮助下,完成了加密和解密脚本, 加密 #!/usr/bin/python # -*- coding: utf- ...

  4. 在linux中使用Sqlplus命令登录MySQL,查看表并设置行数和宽度,使其正常显示

    在linux中使用sqlplus命令进入MySQL,设置行数和行宽   1) 查看目前的pagesize,默认是14: 1.      show pagesize;    2.      set pa ...

  5. PHP在linux上执行外部命令

    PHP在linux上执行外部命令 一.PHP中调用外部命令介绍二.关于安全问题三.关于超时问题四.关于PHP运行linux环境中命令出现的问题 一.PHP中调用外部命令介绍在PHP中调用外部命令,可以 ...

  6. Linux上的free命令详解、swap机制

    Linux上的free命令详解   解释一下Linux上free命令的输出. 下面是free的运行结果,一共有4行.为了方便说明,我加上了列号.这样可以把free的输出看成一个二维数组FO(Free ...

  7. 在linux上用dd命令实现ghost功能

    ghost和g4l 安装操作系统,速度太慢,整个过程太冗长乏味了. 安装过程中,需要回答若干问题,系统需要安装无数个软件,创建和写入无数的文件.因为涉及到大量的文件定位和读写,速度一定是快不起来的. ...

  8. Apache RocketMQ在linux上的常用命令

    Apache RocketMQ在linux上的常用命令 进入maven安装后的rocketmq的bin目录  1.启动Name Server  2.启动Broker 3.关闭Name Server 4 ...

  9. 在linux上使用impdp命令时提示ORA-12154: TNS:could not resolve the connect identifier specified的问题

    今天在一台linux服务器上用impdp命令导入dmp文件时出现了错误: ORA: TNS:could not resolve the connect identifier specified 我使用 ...

随机推荐

  1. day1 java基础回顾-集合

    1.集合 1.1 集合的类型与各自的特性 ---|Collection: 单列集合 ---|List: 有存储顺序, 可重复 ---|ArrayList: 数组实现, 查找快, 增删慢 由于是数组实现 ...

  2. dpdk数据包捕获技术笔记1

    1 高效捕包技术的重要性 高性能系统需要在很短的时间内,成功的收集和处理大量的数据,目标系统的实时数据需要被收集,管里和控制. 2 传统的数据包捕获机制 Inter指出,影响数据包捕获性能主要原因是系 ...

  3. ACM-ICPC2018北京网络赛 80 Days(双端队列+尺取)

    题目4 : 80 Days 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 80 Days is an interesting game based on Jules Ve ...

  4. CentOS软件包管理

    rpm安装包管理 指令 说明 rpm -i XX.rpm 安装XX.rpm软件包 rpm -qa XX 查看XX软件包安装的所有文件 rpm -e XX 卸载XX软件包 yum管理软件 指令 说明 y ...

  5. window.onerror 捕捉所有的前端error

    //[捕捉所有前端error] window.onerror = function (errormessage, url, line, column, error) { console.log(&qu ...

  6. vijos1007 绕钉子的长绳子

    P1007绕钉子的长绳子(https://vijos.org/p/1007) 背景 平面上有N个圆柱形的大钉子,半径都为R,所有钉子组成一个凸多边形. 现在你要用一条绳子把这些钉子围起来,绳子直径忽略 ...

  7. 洛谷P3688/uoj#291. [ZJOI2017]树状数组

    传送门(uoj) 传送门(洛谷) 这里是题解以及我的卡常数历程 话说后面那几组数据莫不是lxl出的这么毒 首先不难发现这个东西把查询前缀和变成了查询后缀和,结果就是查了\([l-1,r-1]\)的区间 ...

  8. 洛谷P2289 [HNOI2004]邮递员(插头dp)

    传送门 太神仙了……讲不来讲不来->这里 //minamoto #include<iostream> #include<cstdio> #include<cstri ...

  9. zabbix 接口 | zabbix api 实践

    原文地址:https://www.jianshu.com/p/d5faa110e78e zabbix 接口地址:https://www.zabbix.com/documentation/3.2/man ...

  10. Laravel Model 利用 Macroable 为数据模型添加宏能力

    什么是ThinkSNS ? ThinkSNS(简称TS),一款全平台综合性社交系统,为国内外大中小企业和创业者提供社会化软件研发及技术解决方案,目前最新版本为ThinkSNS+(简称TS+).Thin ...