ysqladmin -uroot password 'xutaibao' 设置密码mysql
mysql登录
mysql -uroot -h192.168.3.88 -P3306 -ppasswordsql
忘记密码:
vi /etc/my.conf 加入skip-grant
登录MySQL此时不须要密码数据库
use mysql
update user set password=password('xutaibao.blog.51cto.com') where user='root' //更新root密码ide
受权
grant all on *.* to 'root'@'192.168.1.88' identified by '123aaa';post
select * from user where host='192.168.3.88'\G;日志
select user(); 查看用户blog
show databases;查看有那些库
use 库名 切换库队列
select databases();查看在那个库 version 版本ip
show tables; 查看表
desc 表 show create table 查看表建立结构
create database xtb 建立库
create table xtb1 (`id` int(4) `name` char(40)) ENGINE=MyISAM DEFAULT CHARSET=gdk;
insert into biao values(1,'jfkaslf');加内容utf-8
select * from xtb; 查看
insert into biao (`id`) values(2);只加一个字段
insert into biao (`name`) values(‘adf’);
update biao set id=5 where name = '55'
delete from biao where name='55';删除带55行
truncate table xtb.biao 清空biao
drop table biao 删除biao
drop database xtb 删除库
grant all on ku.* to 'user1'@'192.168.0.%' by 'sfasfasdf';受权
flush privileges 刷新权限
show processlist; 查看当前数据库查询队列
hsow variables; 查看变量
set global max_conneceions=200; 更改配置
show variables like 'max_conneceions%' 过滤
show status 查看状态
错误日志
repair table discuz.pre_forum_post; 修复表
mysqldump -uroot -pxutaibao ku > /data/hu.sql 备份库
mysql -uroot -pxutaibao ku < /data/hu.sql 恢复
mysqldump -uroot --default-character-set=gbk -pxutaibao ku biao > /data/hu.sql 指定字符集如 jbk utf-8
mysql主从配置replicarion