root默认是不支持远程登录的,用外网连接必须给权限
1 2 3
| GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '909090' WITH GRANT OPTION;
FLUSH PRIVILEGES;
|
mysql数据库默认是没有密码的,
1 2
| SET PASSWORD FOR 'root'@'localhost' = PASSWORD('909090'); FLUSH PRIVILEGES;
|
init.sql,要尝试将密码去掉,然后scoreShop尝试不用密码是否可以访问到数据库!!!
scoreShop的Dockerfile最终要实现可以再 daocloud.io 上发布!!!
数据库启动命令,根据不同版本有所不同:
1 2 3 4 5 6 7
| chown -R mysql:mysql /var/lib/mysql mysqld --user=mysql &
chown -R mysql:mysql /var/lib/mysql mysql_install_db --user=mysql > /dev/null mysqld_safe --user=mysql &
|
having
1 2
| select id from user group by email having count(*)>1;
|
regexp
1 2 3 4 5 6
| select id,email from user where (id REGEXP '[^0-9]')!=0;
select id,email from user where (id REGEXP '[test.com]')=0;
select id,email from user where (id REGEXP '[test.com]')!=0;
|
导入txt文件数据进入数据库
1 2 3 4 5 6
|
show variables like '%secure%';
LOAD DATA INFILE '/var/lib/mysql-files/users.txt' INTO TABLE users FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n';
|
union all
1 2
| select id from (select id from A UNION ALL select id from B) temptb group by id having count(*)=1;
|
not in
1 2
| select id from user A where A.id not in (select B.id from user B);
|
mysqldump备份恢复数据库
1
| mysqldump -uroot -p -B dbsName -l -R --set-gtid-purged=OFF >dbsName_20190628.sql
|
desc查看表结构