本文共 2957 字,大约阅读时间需要 9 分钟。
将源表复制为新表(Key字段不会被复制)
create table 新表名 select * from 源表; 将指定查询结果复制为新表(Key字段值不会被复制)create table 新表 SQL查询语句; mysql> create table xinbiao select * from mysql.user; mysql>create table xinbiao0 select user,host,password ->from mysql.user;复制源表的结构到新表
create table xb1 select * from 源表 where false(条件为假)或可以随便写个不成立的条件;
2.1)多表查询
select 字段名列表 from 表A,表B;笛卡尔集(表记录个数相乘(表A*表B)的积是查询结果) ----select * from t1,t2 select 字段名列表 from 表A,表B where 条件; -----select t1.* t2.hmoedir from t1,t2 where ti.name="root" and t2.name="root"2.2)where嵌套查询
select 字段名列表 from 表名 where 条件 (select 字段名列表 from 表名 where 条件); -----select name from mysql.t1 where name in (select name from db1.t1); -----select name,age from user where age<(select avg(age) from user); 2.3)左连接查询select 字段名列表 from 表名a left join 表名b on 条件; -----select * from t3 left join t4 on t3.uid = t4.uid; 2.4)右连接查询select 字段名列表 from 表名a right join 表名b on 条件; -----select * from t3 right join t4 on t3.uid = t4.uid;-----------------------------------------------------------------------------------------------
步骤1:yum -y install httpd php php-mysql
systemctl start/enable httpd步骤2:解包,可修改下名字便捷点;部署到网站目录
tar -xf phpMyAdmin-2.11.11-all-languages.tar.gz -C /var/www/html/ cd /var/www/html/ mv phpMyAdmin-2.11.11-all-languages admin(随便取)步骤3:修改软件配置文件
]# cp config.sample.inc.php config.inc.php ]# vim config.inc.php17 $cfg['blowfish_secret'] = 'plj123';31 $cfg['Servers'][$i]['host'] = 'localhost';创建授权用户
4 在客户端254(真机)访问软件 http://192.168.4.50/admin 5 使用数据库管理登陆密码忘了怎么办?
[mysqld]
skip-grant-tables #跳过授权启动mysql服务程序 #validate_password_policy=0 密码策略注释 #validate_password_length=6
]# mysql #直接进数据库
mysql>update mysql.user set authentication_string=password("密码") where user="root" and host="localhost"; mysql>flush privileges; 可参考查看mysql.user的表结构(desc mysql.user)
知道密码的情况下修改密码 ]#mysqladmin -uroot -p旧密码 password "新密码"#skip-grant-tables 注释掉
validate_password_policy=0 #密码策略 validate_password_length=6 plugin-load=validate_password.so #加载模块默认有【可不写】 再重启
修改表记录来修改密码
> update mysql.user set password = password('zhangsannew') where user = 'zhangsan' and host = '%';
> flush privileges;
mysql表下关于权限的表
查看用户的权限
show grants; 查看权限
*.* 所有库所有表,all 匹配所有权限, %匹配所有主机
mysql 授权库
删除用户
1. > drop user 用户@'主机';
2. > delete from mysql.user where user='XXX' and host='localhost';
> flush privileges;
转载地址:http://sriqi.baihongyu.com/