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