Sql实践

1. 负向条件不能使用索引 select id,name from orders where status != 2; not in/not exists 都不太好,可以改写成in 2. 前导模糊查询不能使用索引 select id,name from users where username like '%vilay'; //不使用索引 select id,name from users where username like '

Docker 备份Mysql的方法

在docker中备份mysql的方法 docker exec mysql sh -c "mysqldump -u root -p${password}. ${dbname} ${tablename}" > /path/xxx.sql mysql可以是mysql容器的名称或者id

Centos 8 安装Mysql8

Centos 8在mysql官网那边找不到对应版本的5.7版本的Mysql。 1. 下载 wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm 2. 安装 rpm -ivh mysql80-community-release-el8-1.noarch.rpm yum install mysql-server 3. 设置开机启动 systemctl enable mysqld.service 4. 登录修改密码 mysql -u root -p alter user 'root'@'localhost'