创建数据库:
$ mysqladmin -uroot create gallery2 $ mysql gallery2 -uroot -e"GRANT ALL ON gallery2.* TO username@localhost IDENTIFIED BY 'password'"
若出错,可在-uroot 后跟上-p 并输入root的密码。连接mysql:mysql -p,然后在密码提示下输入密码,当然这是连接本地默认mysql的简便写法。然后:
mysql> status; -------------- mysql Ver 14.14 Distrib 5.5.24, for debian-linux-gnu (x86_64) using readline 6.2 Connection id: 47 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.5.24-0ubuntu0.12.04.1 (Ubuntu) Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /var/run/mysqld/mysqld.sock Uptime: 39 min 33 sec Threads: 2 Questions: 148 Slow queries: 0 Opens: 239 Flush tables: 1 Open tables: 58 Queries per second avg: 0.062 --------------
显示数据库的一些信息。可以看到当前未指定数据库。
列出当前数据库。mysql> show databases;
使用某数据库:mysql> use gallery2;
列出所有表:show tables;
其余部份使用一般sql操作大约就能完成了。
原创文章,作者:苏葳,如需转载,请注明出处:https://www.swmemo.com/480.html