MySql基本操作

MySQL:应用场景(互联网企业,扩展性强)
mysql 是一个客户端命令

quit 退出

mysql -u 'tedu@192.168.0.199' -p

\c 退出当前行输入

status; 显示基本信息

//建库
create database ttms_lmg default character set utf8;
//建表
create table t1 if not exists t1(
-> id int primary key,
-> title varchar(50),
-> createtime datetime);

//建表后修改字符集
alter database ttms default character set utf8;

//更改字符集
create database aaa;
set names utf8;
use aaa;

//添加判断,表存在则删除
drop table if exists t1

数据库表数据的CRUD操作
insert select update delete

//使用帮助文档,使用help等价与?
? drop database ?create database ?int ?bigint
? function 查看系统中有那些函数
? now

select now(); 显示当前时间

insert into t1 (createtime)values (now());

set foreign_key_checks=0; 设置不检查外键约束

set names utf8;
source d:/ttms01.sql 引入外部.sql文件(window系统下)
source /home/soft01/test.sql; (linux系统下)

======================================================================

【====Linux系统配置启动MySQL=====】

[soft01@cpe-172-88-7-187 桌面]$ su root;
密码:tarenamiszhengzhou


[root@cpe-172-88-7-187 桌面]# rm -rf /var/lib/mysql/mysql.sock;
[root@cpe-172-88-7-187 桌面]# service mysqld restart;
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[soft01@cpe-172-88-7-187 桌面]$ mysql -uroot;

 

Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.71 Source distribution

Copyright (c) 2000, 2013, 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> Ctrl-C -- exit!
Aborted
[soft01@cpe-172-88-7-187 桌面]$

 

posted @ 2017-09-26 15:12  lmg6406  阅读(192)  评论(0编辑  收藏  举报