标签:服务 student arc efault 单个字符 min show gen tab
一,安装后1,Linux下安装完后root密码为空,使用以下命令创建密码
[root@host]# mysqladmin -u root password "new_password";
2,连接到MySQL服务器
[root@host]# mysql -u root -p
Enter password:*******
3,退出quit或exit
[root@host]# quit
[root@host]# exit
1,查看所有数据库
[root@host]# show databases;
2,创建数据库
[root@host]# create database 数据库名 charset utf8;
3,删除数据库
[root@host]# drop database 数据库名;
4,切换数据库
[root@host]# use 数据库名;
5,查看正在使用的数据库
[root@host]# select database();
1,查看数据库中所有表
[root@host]# show tables;
2,创建表
[root@host]# create table 表名(列 类型);
Example
[root@host]# create table student(
id int auto_increment primary key,
name varchar(20) not null,
gender tinyint not null,
address varchar(40),
isDelete tinyint default 0
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
3,删除表
[root@host]# drop table 表名;
4,查看表结构
[root@host]# desc 表名;
1,插入数据
INSERT INTO table_name ( field1, field2,...fieldN )
VALUES
( value1, value2,...valueN );
2,where语句
SELECT field1, field2,...fieldN FROM table_name1, table_name2...
[WHERE condition1 [AND [OR]] condition2.....
3,查询数据
SELECT column_name,column_name
FROM table_name
[WHERE Clause]
[LIMIT N][ OFFSET M]
4,UPDATE 查询
UPDATE table_name SET field1=new-value1, field2=new-value2
[WHERE Clause]
5,DELETE 语句
DELETE FROM table_name [WHERE Clause]
5,LIKE 子句
SELECT field1, field2,...fieldN
FROM table_name
WHERE field1 LIKE condition1 [AND [OR]] filed2 = ‘somevalue‘
Example
mysql> use RUNOOB;
Database changed
mysql> SELECT * from runoob_tbl WHERE runoob_author LIKE ‘%COM‘;
+-----------+---------------+---------------+-----------------+
| runoob_id | runoob_title | runoob_author | submission_date |
+-----------+---------------+---------------+-----------------+
| 3 | 学习 Java | RUNOOB.COM | 2015-05-01 |
| 4 | 学习 Python | RUNOOB.COM | 2016-03-06 |
+-----------+---------------+---------------+-----------------+
2 rows in set (0.01 sec)
最后附一篇MySQL添加用户、删除用户与授权的博客,链接。
标签:服务 student arc efault 单个字符 min show gen tab
原文地址:http://blog.51cto.com/13592676/2293961