89ou 发表于 2018-8-23 08:27:21

Shell操作MySQL方法

方式一:
  # mysql   -uroot-h 127.0.0.1-p
  -u username
  -hhost_ip
  -p“new_pass”
  -D db_name                        //指定直接进入的数据库
  -e“sql_language”               //直接在交互中直接执行SQL语句
  例如: mysql-uroot-hlocalhost-pmypass-Dmysql-e“SELECT user,host,passwordfromuser;”
http://blog.51cto.com/e/u261/themes/default/images/spacer.gif
方式二:批处理模式
  # mysql   -uroot .......<   mysql.sql
  例如:
  mysql.sql:
http://blog.51cto.com/e/u261/themes/default/images/spacer.gif
  #mysql-uroot -hlocalhost-proot<mysql.sql
http://blog.51cto.com/e/u261/themes/default/images/spacer.gif
方式三:
  mysql >   source/path/to/mysql.sql

页: [1]
查看完整版本: Shell操作MySQL方法