zoukankan      html  css  js  c++  java
  • mysql 内部命令使用和mysqladmin用法

    MySQL的命令

    1.mysql内部快捷命令

    c:		终止正在输入的命令
    	
    :		重新连接数据库
    	d:		修改sql语句结束符
    	e:		输出输入的内容
    G:		以key:values形式展示数据
    q:		退出数据库
    	g:		结束语句
    	h: 	查看帮助
    	T:		输出一个文件记录操作
    		:		终止记录操作的文件
    	p:		打印输入的命令
    	R:		 临时修改命令提示符
    .		导入sql语句,等于 source 命令
    	s:		查看数据库连接状态
    !:		在数据库里执行命令行命令
    u		切换数据库,等于 use 命令
    

    2.help命令

    #查看数据库内命令语法
    mysql> help
    mysql> help create database
    mysql> help create table
    mysql> help select
    

    2.客户端mysqladmin命令

    1)设置密码

    #1.设置密码
    [root@db02 ~]# mysqladmin -uroot password
    New password: 
    Confirm new password:
    
    #2.修改密码
    [root@db02 ~]# mysqladmin -uroot -p password
    Enter password: 
    New password: 
    Confirm new password:
    

    2)关闭服务

    [root@db02 ~]# mysqladmin -uroot -p shutdown 
    Enter password: 123
    

    3)库外建库

    [root@db02 ~]# mysqladmin -uroot -p123 create database222222
    

    4)库外删库

    [root@db02 ~]# mysqladmin -uroot -p123 drop database222222
    Warning: Using a password on the command line interface can be insecure.
    Dropping the database is potentially a very bad thing to do.
    Any data stored in the database will be destroyed.
    
    Do you really want to drop the 'database222222' database [y/N] y
    Database "database222222" dropped
    

    5)查看数据库配置

    [root@db02 ~]# mysqladmin -uroot -p123 variables | grep -w server_id
    

    6)检测数据库是否启动

    [root@db02 ~]# mysqladmin -uroot -p ping
    Enter password: 
    mysqld is alive
    

    7)查看数据库信息

    [root@db02 ~]# mysqladmin -uroot -p123 status
    Warning: Using a password on the command line interface can be insecure.
    Uptime: 130  Threads: 1  Questions: 94  Slow queries: 0  Opens: 70  Flush tables: 1  Open tables: 63  Queries per second avg: 0.723
    
    Slow queries: 0
    Queries per second avg: 0.723
    

    8)刷新授权表

    [root@db02 ~]# mysqladmin -uroot -p123 reload
    

    9)刷新binlog

    [root@db02 ~]# mysql -uroot -p123 -e "show master status"
    Warning: Using a password on the command line interface can be insecure.
    +------------------+----------+--------------+------------------+-------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+----------+--------------+------------------+-------------------+
    | mysql-bin.000001 |      120 |              |                  |                   |
    +------------------+----------+--------------+------------------+-------------------+
    
    #刷新binlog
    [root@db02 ~]# mysqladmin -uroot -p123 flush-logs 
    Warning: Using a password on the command line interface can be insecure.
    
    #再次查看binlog
    [root@db02 ~]# mysql -uroot -p123 -e "show master status"
    Warning: Using a password on the command line interface can be insecure.
    +------------------+----------+--------------+------------------+-------------------+
    | File             | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
    +------------------+----------+--------------+------------------+-------------------+
    | mysql-bin.000002 |      120 |              |                  |                   |
    +------------------+----------+--------------+------------------+-------------------+
    
  • 相关阅读:
    Linq增删查改
    AspNetPager 分页显示
    简单C#数据库操作类
    SQL重复记录处理(查找,过滤,删除)
    Asp.Net配置Web.config连接数据库SqlServer
    转:Asp.Net网站项目发布到IIS后验证码不能显示的问题解决
    将一行含有日期范围的数据按照单日日期拆分
    asp.net过滤HTML标签的几个函数
    循环批量更新的的存储过程(属于转载)
    CheckBox的CheckedChanged事件获取所在GridView中的Cell值
  • 原文地址:https://www.cnblogs.com/xiaolang666/p/13858399.html
Copyright © 2011-2022 走看看