本文共 1218 字,大约阅读时间需要 4 分钟。
在数据库中操作是日常工作的重要部分,以下是常用的数据库操作命令:
create database mydatabase;
show databases;
drop database mydatabase;
use mydatabase;
create table mytable( id int(4) not null primary key auto_increment, name char(255), score float(8,2));
drop table mytable;
insert into mytable (id,name,score) values(1,"tom",93.65);
select * from mytable;
select * from mytable where score > 60;
rename mytable to newtable;
alter table mytable2 add brother int(4) default 0;
delete from mytable where id in (20,21,22,23);
use mysqlselect user, host from user;
delete from user where host="%";
create user 'root'@'localhost' identified by '密码';grant all privileges on *.* to root@IP地址;flush privileges;
service mysqld restart
update user set password="新密码" where user="用户名";
#!/bin/bashcd /usr/bin && ./mysqldump -hlocalhost -u"数据库名称" -p"数据库密码" mydb > /root/DBBackup/$(date +%Y%m%d).bakcd /root
- **执行权限**: ```bashchmod 777 your.sh
crontab -e
添加以下行:
* 23:59 * * * /root/your.sh
通过以上操作,您可以轻松管理数据库,确保数据安全和稳定性。
转载地址:http://acbfk.baihongyu.com/