mysql 建立資料庫和表

2022-06-23 08:51:10 字數 1189 閱讀 1488

mysql 建立資料庫和表

[root@localhost ~]# service mysqld start                   //啟動mysql伺服器

[root@localhost ~]# mysqladmin -u root password "642531"   //為mysql使用者root設定登入密碼

[root@localhost ~]# mysql -u root -p                   //以root使用者身份登入mysql伺服器

enter password:                   //輸入密碼"642531"

mysql> create database news;        //建立資料庫news

mysql> use news;                 //使用資料庫news

//建立表user_msg,裡面儲存論壇成員的使用者名稱和密碼,用於登入論壇

mysql> create table user_msg(name varchar(40),password varchar(40));

mysql> insert into user_msg(name,password) values('ztg', '642531');     //新增論壇成員ztg

//建立表bbs_subject,裡面儲存論壇的所有主題

mysql> create table bbs_subject(id int(9) not null auto_increment,subject varchar(100) not null,send_time datetime,auth varchar(20) not null,reply int(9) default '0' not null,hits int(9) default '0' not null,last_time datetime,primary key (id));

//建立表bbs_content,裡面儲存論壇的所有帖子資訊

mysql> create table bbs_content(id int(9) not null auto_increment,subject_no int(9) default '0' not null,name varchar(20) not null,postdate datetime,msg text,primary key (id));

0給主人留下些什麼吧!~~

mysql建立資料庫和表!

create database searchdb use searchdb create table product id int auto increment,category varchar 128 name varchar 128 type varchar 128 content varcha...

mysql 建立資料庫和表

mysql 建立資料庫和表 root localhost service mysqld start 啟動mysql伺服器 root localhost mysqladmin u root password 642531 為mysql使用者root設定登入密碼 root localhost mysql...

mysql建立資料庫和表

連線mysql伺服器 shell mysql uroot p 利用quit退出。檢視目前伺服器中擁有的資料庫 mysql show databases 使用資料庫時需要宣告 mysql use test 建立乙個新的資料庫 mysql create database menagerie mysql ...