Mysql 初学基本

    xiaoxiao2026-06-20  8

    Mysql 基本命令

    今天自己巩固下自己关于mysql常用的命令。

    mysql的登陆、登出

    登陆操作 mysql -uUserName -pPassword(一般在自己机子中采用默认端口和host)

    附上:mysql 其他命令参数 -D,–dataname=name 打开指定数据库 -delimiter=name 指定分隔符(默认为;) -h,–host=name 服务器名称 -p,–password[=name] 密码 -P(大写),–port=name 端口号 –prompt=name 设置提示符 -u,–user=name 用户名 -V(大写),–version 输出版本信息并退出 2. 登出操作

    1 mysql > exit 2 mysql > quit 3 mysql > \q

    提示符

    1.prompt命令可以在mysql提示符中显示当前用户、数据库、时间等信息

    mysql -uroot -p --prompt="\\u@\\h:\\d \\r:\\m:\\s>"

    2.mysql client中

    mysql>Prompt [name];

    选项说明:

    Option Description \c A counter that increments for each statement you issue \D The full current date \d The default database \h The server host \l The current delimiter (new in 5.1.12) \m Minutes of the current time \n A newline character \O The current month in three-letter format (Jan, Feb, …) \o The current month in numeric format \P am/pm \p The current TCP/IP port or socket file \R The current time, in 24-hour military time (023) \r The current time, standard 12-hour time (112) \S Semicolon \s Seconds of the current time \t A tab character \u username

    3.在my.cnf配置文件里进行配置

    [mysql] prompt=mysql(\\u@\\h:\\d)> default-character-set=utf8

    常用命令

    显示当前服务器版本SELECT VERSION();显示日期时间SELECT NOW();显示当前用户SELECT USER(); -

    语句规范

    关键字与函数全部大写名称、表名称,字段全部小写SQL语句必须以分号结尾
    转载请注明原文地址: https://ju.6miu.com/read-1310702.html
    最新回复(0)