mysqladmin -u root -password ab12
mysqladmin -u root -p ab12 password djg345
grant select,insert,update,delete on *.* to [email=test1@”%]test1@”%[/email]” Identified by “abc”;
grant select,insert,update,delete on mydb.* to [email=test2@localhost]test2@localhost[/email] identified by “”;
mysql> drop database drop_database; Query OK, 0 rows affected (0.00 sec)
mysql> drop database drop_database; ERROR 1008 (HY000): Can't drop database 'drop_database'; database doesn't exist //发生错误,不能删除'drop_database'数据库,该数据库不存在。 mysql> drop database if exists drop_database; Query OK, 0 rows affected, 1 warning (0.00 sec)//产生一个警告说明此数据库不存在 mysql> create database drop_database; Query OK, 1 row affected (0.00 sec) mysql> drop database if exists drop_database;//if exists 判断数据库是否存在,不存在也不产生错误 Query OK, 0 rows affected (0.00 sec)
mysql> USE db1; mysql> SELECT COUNT(*) FROM mytable; # selects from db1.mytable mysql> USE db2; mysql> SELECT COUNT(*) FROM mytable; # selects from db2.mytable
mysql> USE db1; mysql> SELECT author_name,editor_name FROM author,db2.editor -> WHERE author.editor_id = db2.editor.editor_id;
mysql> select version(); +-----------------------+ | version() | +-----------------------+ | 6.0.4-alpha-community | +-----------------------+ 1 row in set (0.02 sec)
mysql> select now(); +---------------------+ | now() | +---------------------+ | 2009-09-15 22:35:32 | +---------------------+ 1 row in set (0.04 sec)
SELECT DAYOFMONTH(CURRENT_DATE); +--------------------------+ | DAYOFMONTH(CURRENT_DATE) | +--------------------------+ | 15 | +--------------------------+ 1 row in set (0.01 sec) SELECT MONTH(CURRENT_DATE); +---------------------+ | MONTH(CURRENT_DATE) | +---------------------+ | 9 | +---------------------+ 1 row in set (0.00 sec) SELECT YEAR(CURRENT_DATE); +--------------------+ | YEAR(CURRENT_DATE) | +--------------------+ | 2009 | +--------------------+ 1 row in set (0.00 sec)
mysql> SELECT "welecome to my blog!"; +----------------------+ | welecome to my blog! | +----------------------+ | welecome to my blog! | +----------------------+ 1 row in set (0.00 sec)
select ((4 * 4) / 10 ) + 25; +----------------------+ | ((4 * 4) / 10 ) + 25 | +----------------------+ | 26.60 | +----------------------+ 1 row in set (0.00 sec)
select CONCAT(f_name, " ", l_name) AS Name from employee_data where title = 'Marketing Executive'; +---------------+ | Name | +---------------+ | Monica Sehgal | | Hal Simlai | | Joseph Irvine | +---------------+ 3 rows in set (0.00 sec)
id int 4 否 primary key auto_increment name char 20 否 sex int 4 否 0 degree double 16 是 mysql> create table MyClass( > id int(4) not null primary key auto_increment, > name char(20) not null, > sex int(4) not null default '0', > degree double(16,2));
mysql> insert into MyClass values(1,'Tom',96.45),(2,'Joan',82.99), (2,'Wang', 96.59);
mysql> select * from MyClass;
mysql> select * from MyClass order by id limit 0,2;
mysql> delete from MyClass where id=1;
FirstName LastName Age Peter Griffin 35 Glenn Quagmire 33
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
mysql_query("DELETE FROM Persons WHERE LastName='Griffin'"); mysql_close($con);
?>
FirstName LastName Age Glenn Quagmire 33
mysql> update MyClass set name='Mary' where id=1;
UPDATE [LOW_PRIORITY] [IGNORE] tbl_name SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition] [ORDER BY ...] [LIMIT row_count]
UPDATE [LOW_PRIORITY] [IGNORE] table_references SET col_name1=expr1 [, col_name2=expr2 ...] [WHERE where_definition]
mysql> alter table MyClass add passtest int(4) default '0'
mysql> alter table employee add index emp_name (name);
mysql> alter table 表名 add primary key (字段名);
mysql> alter table employee add primary key(id);
mysql> alter table 表名 add unique 索引名 (字段名);
mysql> alter table employee add unique emp_name2(cardnumber);
mysql> alter table 表名 drop index 索引名;
mysql>alter table employee drop index emp_name;
mysql> ALTER TABLE table_name ADD field_name field_type;
mysql> ALTER TABLE table_name CHANGE old_field_name new_field_name field_type;
MySQL ALTER TABLE table_name DROP field_name;
mysql> rename table MyClass to YouClass;
mysqldump -u user_name -p123456 database_name > outfile_name.sql
mysqldump -u user_name -p database_name table_name > outfile_name.sql
mysqldump -u user_name -p -d –add-drop-table database_name > outfile_name.sql
mysqldump -uroot -p –default-character-set=latin1 –set-charset=gbk –skip-opt database_name > outfile_name.sql
drop database if exists school; //如果存在SCHOOL则删除 create database school; //建立库SCHOOL use school; //打开库SCHOOL create table teacher //建立表TEACHER ( id int(3) auto_increment not null primary key, name char(10) not null, address varchar(50) default ‘深圳', year date ); //建表结束 //以下为插入字段 insert into teacher values(”,'allen','大连一中','1976-10-10′); insert into teacher values(”,'jack','大连二中','1975-12-23′);
drop database if exists school; //如果存在SCHOOL则删除
create database school; //建立库SCHOOL
use school; //打开库SCHOOL
create table teacher //建立表TEACHER
(
id int(3) auto_increment not null primary key,
name char(10) not null,
address varchar(50) default ''深圳'',
year date
); //建表结束
//以下为插入字段
insert into teacher values('''',''glchengang'',''深圳一中'',''1976-10-10'');
insert into teacher values('''',''jack'',''深圳一中'',''1975-12-23'');
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有