mysql学习笔记
select substring(now(),1,10);
mysql登陆 大写字母P是端口
C:\Program Files\MySQL\MySQL Server 5.6\bin>
mysql -h 127.0.0.1 -P -u root -p
设置root账户的密码
mysql> set password for ‘xp‘@‘127.0.0.1‘=password(‘xp132018‘);
修改密码:
C:\Program Files\MySQL\MySQL Server 5.6\bin>mysqladmin -u root -ppasswd password abc
mysql数据库远程:
grant all PRIVILEGES on *.* to ‘root‘@‘192.168.0.%‘ identified by ‘3613571‘;
flush privileges;
(第一个*是数据库,第二个* 表示数据库中的表, win代表账户,%代表ip地址, win456 代表账户密码)
show databases;
use TD_OA;
show tables;
select * from user;
select * into outfile ‘d:/test.xls‘ from 表名
create table aaa (ID INT(11),NAME varchar(255));
insert into student values(‘102‘,‘李四‘,‘八年级‘);
drop table student; 删除表
数据库的备份
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysqldump.exe -u root -p mysql student > mysql_bak.sql (备份指定的mysql数据库的student表)
mysqldump.exe -u root -p mysql > mysql_bak.sql (备份数据库mysql中的全部表)
数据库的还原
C:\Program Files\MySQL\MySQL Server 5.5\bin>mysql -u root -p mysql < mysql_bak.sql
grant replication slave on *.* to ‘xp‘@‘192.168.1.9‘ identified by ‘xp456‘ with grant option;
change master to master_host=‘192.168.1.10‘,master_user=‘xp‘,master_password=‘xp456‘,master_log_file=‘mysql-bin.000013‘ ,master_log_pos=107;
mysql 服务的安装
mysqld --install MySQL --defaults-file=D:\hyk\mysql55\my.ini
net start mysql
mysql服务的卸载
net stop mysql
mysqld -remove