这个方式与Oracle SQL*plus下的help 是类似的。
mysql>help
For information about MySQL products and services, visit:
http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
http://dev.mysql.com/
To buy MySQL Enterprise support, training, or other products, visit:
https://shop.mysql.com/
List of all MySQL commands:
Note that all text commands must be first on line and end with ''
? (\?) Synonym for `help'.
clear (\c) Clear the current input statement. --清除当前输入的语句
connect (\r) Reconnect to the server. Optional arguments are db and host. --重新连接,通常用于被剔除或异常断开后重新连接,SQL*plus下也有这样一个connect命令
delimiter (\d) Set statement delimiter. --设置命令终止符,缺省为;,比如我们可以设定为/来表示语句结束
edit (\e) Edit command with $EDITOR. --编辑缓冲区的上一条SQL语句到文件,缺省调用vi,文件会放在/tmp路径下
ego (\G) Send command to mysql server, display result vertically. --控制结果显示为垂直显示
exit (\q) Exit mysql. Same as quit. --退出mysql
go(\g) Send command to mysql server. --发送命令到mysql服务
help (\h) Display this help.
nopager (\n) Disable pager, print to stdout.--关闭页设置,打印到标准输出
notee (\t) Don't write into outfile. --关闭输出到文件
pager (\P) Set PAGER [to_pager]. Print the query results via PAGER. --设置pager方式,可以设置为调用more,less等等,主要是用于分页显示
print (\p) Print current command.
prompt(\R) Change your mysql prompt. --改变mysql的提示符
quit (\q) Quit mysql.
rehash(\#) Rebuild completion hash. --自动补齐相关对象名字
source(\.) Execute an SQL script file. Takes a file name as an argument. --执行脚本文件
status(\s) Get status information from the server.--获得状态信息
system(\!) Execute a system shell command.--执行系统命令
tee (\T) Set outfile [to_outfile]. Append everything into given outfile.-- *** 作结果输出到文件
use (\u) Use another database. Takes database name as argument. --切换数据库
charset (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets. --设置字符集
warnings (\W) Show warnings after every statement. --打印警告信息
nowarning (\w) Don't show warnings after every statement.
--上面的所有命令,扩号内的为快捷 *** 作,即只需要输入“\”+ 字母即可执行
For server side help, type 'help contents'--注意这里的描述help contents将获得服务器端的相关帮助信息
--演示部分,演示常用命令
--connect命令
mysql>connect chardb localhost
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Connection id:5
Current database: chardb
--设置分页,在多余一个页面显示时会不停的翻滚,用该命令可以设置分页,设置为调用系统命令
mysql>pager more --设置为more方式
PAGER set to 'more'
mysql>select table_name,table_type,engine from information_schema.tables --该查询会超出一屏显示后按空格键会自动翻滚到下一屏
mysql>pager tail -5 --设置输出尾部5行
PAGER set to 'tail -5'
mysql>select table_name,table_type,engine from information_schema.tables
| setup_timers | BASE TABLE | PERFORMANCE_SCHEMA |
| threads | BASE TABLE | PERFORMANCE_SCHEMA |
| animals | BASE TABLE | InnoDB |
| shop | BASE TABLE | InnoDB |
+----------------------------------------------+-------------+--------------------+
92 rows in set (0.02 sec)
mysql>pager --查看当前的pager设置
PAGER set to 'tail -5'
mysql>nopager --切换到标准(缺省)pager方式
PAGER set to stdout
--tee命令,输出日志文件
mysql>tee /tmp/query.log--开启输出到文件,相当与SQL*plus下的spool
Logging to file '/tmp/query.log'
mysql>select table_name,table_type,engine from information_schema.tables
+----------------------------------------------+-------------+--------------------+
| table_name | table_type | engine |
+----------------------------------------------+-------------+--------------------+
| CHARACTER_SETS | SYSTEM VIEW | MEMORY |
| COLLATIONS | SYSTEM VIEW | MEMORY |
.............
mysql>notee --关闭输出到文件,相当于SQL*Plus下的spool off
Outfile disabled.
mysql>system tail /tmp/query.log--查看输出的日志文件
| setup_consumers | BASE TABLE | PERFORMANCE_SCHEMA |
| setup_instruments| BASE TABLE | PERFORMANCE_SCHEMA |
| setup_timers | BASE TABLE | PERFORMANCE_SCHEMA |
| threads | BASE TABLE | PERFORMANCE_SCHEMA |
| animals | BASE TABLE | InnoDB |
| shop | BASE TABLE | InnoDB |
+----------------------------------------------+-------------+--------------------+
92 rows in set (0.02 sec)
--改变mysql提示符
mysql>prompt SessionA>
PROMPT set to 'SessionA>'
--恢复到缺省提示符
SessionA>prompt
Returning to default PROMPT of mysql>
--执行sql脚本文件
mysql>system more query.sql --注意,此时为当前目录
use chardb
select * from tb_isam
mysql>source query.sql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
+------+-------+
| id | value |
+------+-------+
|1 | a |
|2 | b |
|3 | c |
|4 | f |
+------+-------+
4 rows in set (0.00 sec)
--获取状态信息
mysql>status
--------------
mysql Ver 14.14 Distrib 5.5.37, for Linux (x86_64) using readline 5.1
Connection id: 6
Current database: chardb
Current user: root@localhost
SSL:Not in use
Current pager: less
Using outfile: ''
Using delimiter:
Server version: 5.5.37-log MySQL Community Server (GPL)
Protocol version: 10
Connection: Localhost via UNIX socket
Server characterset:latin1
Db characterset:utf8
Client characterset:latin1
Conn. characterset:latin1
UNIX socket:/var/lib/mysql/mysql.sock
Uptime: 3 hours 10 min 59 sec
Threads: 1 Questions: 97 Slow queries: 0 Opens: 313 Flush tables: 1 Open tables: 51 Queries per second avg: 0.008
--------------
--修改客户端字符集
想知道linux下怎么修改密码吗?下面由我为大家整理了linux mysql修改密码命令,希望大家喜欢!
linux mysql修改密码命令
1.修改root密码
linux mysql修改密码命令方法1:使用mysqladmin命令
--适用于记得root旧密码,修改root密码
语法:
mysqladmin -u用户名 -p旧密码 password 新密码
例如:
# mysqladmin -u root -proot password mysql
--注意:如当旧密码输入错误时会报如下错误
# mysqladmin -u root -proot1 password mysql
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
linux mysql修改密码命令方法2:直接更新user表password字段
--适用于忘记root密码,而对root密码进行重置
Step 1: 修改MySQL的登录设置
# vi /etc/my.cnf
--windows系统是my.ini文件
--在[mysqld]的段中加上一句:skip-grant-tables,如没有[mysqld]字段,可手动添加上
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
skip-name-resolve
skip-grant-tables
Step 2: 重新启动mysql
[root@gc ~]# service mysql restart
Shutting down MySQL..[确定]
Starting MySQL...[确定]
Step 3: 登录并修改MySQL的root密码
--此时直接用mysql即可无需密码即可进入数据库了
[root@gc ~]# mysql
Welcome to the MySQL monitor. Commands end with or \g.
Your MySQL connection id is 2
Server version: 5.5.24 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help' or '\h' for help. Type '\c' to clear the current input statement.
mysql>use mysql
Database changed
mysql>update user set password=password('new_password') where user='root'
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5 Changed: 5 Warnings: 0
mysql>flush privileges
Query OK, 0 rows affected (0.00 sec)
--注意:如果没做step1,直接用mysql登录时会报如下错误
[root@gc ~]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
Step 4: 将MySQL的登录设置修改回来
再删除/etc/my.cnf文件中的skip-grant-tables
Step 5: 重新启动mysql
[root@gc ~]# service mysql restart
Shutting down MySQL..[确定]
Starting MySQL...[确定]
2.修改mysql其它用户密码
同样,普通用户也可以用上面的方法
--使用mysqladmin命令
[root@njdyw ~]# mysqladmin -u user1 -ppass1 password pass2
--直接修改数据库表
[root@njdyw ~]# mysql -u user1 -ppass1 –Dmysql
mysql>update user set password=password('pass2') where user='user1'
mysql>flush privileges
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)