MySql基本操作
Posted lmg6406
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MySql基本操作相关的知识,希望对你有一定的参考价值。
mysql:应用场景(互联网企业,扩展性强)
mysql 是一个客户端命令
quit 退出
mysql -u ‘[email protected]‘ -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=====】
[[email protected] 桌面]$ su root;
密码:tarenamiszhengzhou
[[email protected] 桌面]# rm -rf /var/lib/mysql/mysql.sock;
[[email protected] 桌面]# service mysqld restart;
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[[email protected] 桌面]$ 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
[[email protected] 桌面]$
以上是关于MySql基本操作的主要内容,如果未能解决你的问题,请参考以下文章