Monday, December 31, 2012

Mysql笔记

1.按默认目录(c:\mysql)安装
2.运行mysqld-max-nt -install,将mysql添加到服务中,可以运行mysqld-max-nt -remove从服务中删除MySql
3.运行net start Mysql启动mysql服务,可以运行net stop Mysql停止mysql服务
4.敲入mysql,按回车进入mysql>
5.show databases; 命令显示当前所有数据库(mysql、test)
6.use mysql;进入mysql数据库,show tables;显示当前数据库(mysql)中所有的表。并可对表做需要的操作

Mysql默认root用户密码是空
    % mysql -u root -p
    password: *****
    mysql> create database roller;
    mysql> grant all on roller.* to scott identified by 'tiger';
    mysql> grant all on roller.* to scott@localhost identified by 'tiger';
    mysql> use roller;
    mysql> source createdb-mysql.sql
    mysql> quit



C:\>mysql --user=root mysql
mysql> grant all privileges on *.* to radarsdev@localhost identified by 'radarsd
ev' with grant option;
C:\>mysql --user=radarsdev@localhost   or C:\>mysql --user=radarsdev --password=radarsdev
mysql> show databases;

新笔记:
MySQL简明使用(以4.0.16-max-nt为例)
1.下载mysql-4.0.16-win.zip,解压后双击SETUP.EXE,以典型方式安装到默认目录c:\mysql
2.命令行运行net start mysql启动mysql服务
3.将mysql的安装目录(这里是c:\mysql)添加到系统path环境变量中,以方便以后使用
4.命令行执行mysql --user=root mysql,表示以root身份使用mysql数据库,
  mysql>status   可以看到当前使用的数据库和当前用户
5.创建新用户jive
  mysql> GRANT ALL PRIVILEGES ON *.* TO jive@localhost
    -> IDENTIFIED BY 'jive' WITH GRANT OPTION;  
6.使用mysql>show databases;命令可以查看当前已有的数据库列表。
7.创建数据库jive:
  mysql>create database jive;    --删除使用crop database jive;
8.将数据库切换到jive:
  mysql>use jive;  
9.执行脚本Jive_mysql.sql:
  mysql>source c:\Jive_mysql.sql;  
10.使用mysql>show tables;命令查看当前数据库下的table列表。
现在,您可以使用jive了,使用quit退出mysql。实际上,安装目录下的Docs目录下的manul讲的非常详细,
是很好的参考。


C:\>mysql --user=root mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 14 to server version: 4.0.12-max-nt

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> GRANT ALL PRIVILEGES ON *.* TO jive@localhost
    -> IDENTIFIED BY 'jive' WITH GRANT OPTION;
Query OK, 0 rows affected (0.13 sec)

10.
c:\mysql\bin\winmysqladmin.exe Database 创建数据库test
mysql>use test;
利用source或.\ 执行。sql文件
mysql>source c:\ch02.sql
如果要在MySQL上使用中文的话,需加参数:
useUnicode = true&characterEncoding=gb2312
即url为:jdbc:mysql://localhost/chSamples?useUnicode=true&characterEncoding=gb2312
否则会出现乱码

11.
MySQL添加用户的方法是在库MySQL的表user中添加,也可用如下sql:
Grant 权限 on 库.表 to root@localhost identified by 'password';
如:grant all on * to root@localhost identified by 'password';

12.
MySQL中,select * from userinfo limit4,5;
limit 起始条目,显示条目数

No comments:

Post a Comment