MySql基本操作

2022-08-09 05:00:07 字數 1790 閱讀 6138

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

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

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 桌面]$

mysql基本操作 MySQL基本操作

mysql中新增使用者,新建資料庫,使用者授權,刪除使用者,修改密碼 注意每行後邊都跟個 表示乙個命令語句結束 1.新建使用者 1.1 登入mysql mysql u root p 密碼 1.2 建立使用者 mysql insert into mysql.user host,user,passwor...

mysql 基本操作 mysql基本操作

mysql 建立表,並設定主鍵自增 create table log logid int 4 primary key not null auto increment,logtitle varchar 32 not null logcontent varchar 160 not null logtim...

mysql基本操作

1,檢視資料庫狀態 及啟動停止 etc init.d mysqld status etc init.d mysqld start etc init.d mysqld stop 2,給使用者配置初始密碼123456 mysqladmin u root password 123456 3,修改root使...