WishMeLz

生活其实很有趣

Mysql操作

远程链接
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'a123456!' WITH GRANT OPTION;

修改密码

SET PASSWORD = PASSWORD('Abc123!_');

命令立即生效
flush privileges;

启动
service mysqld start  

查看位置
which mysql

查看配置文件位置
mysql --help | grep 'Default options' -A 1

重置密码
skip-grant-tables
service mysqld start 启动
service mysql stop 关闭
update mysql.user set authentication_string=password('password') where user='root'; 修改密码

增删改查询
INSERT INTO table set ?
UPDATE   table  SET ? WHERE id =?
DELETE FROM table WHERE id=?

复制数据:
insert into table_name(column_name1,column_name2) select c,'11' from b where x=xxxxx(这个是b表的筛选条件)
select c , '11' as num from b where x=x(每一条数据添加一份num数据)

insert into user(uername, psd, status) select username, psd, '12' as status from status = '1' (在user表中将status为1的数据复制一份给status为12的)