MySQL常用操作

创建mysql用户和数据表

create database testcom;

grant all on testcom.* to 'cxf'@'localhost' identified by 'cxf';

MySQL的密码重置

设置root密码为123456

mysql -uroot password '123456'

vim /etc/my.cnf

在最后面加一条

skip-grant

不去授权

登录mysql重置密码,重置后要把skip-grant去掉

use mysql;

update user set password=password('123456') where user='root';

刷新磁盘:flush privileges(也可以重启)

mysql登录

mysql -uroot -h127.0.0.1 -P3306 -p123456

授权192.168.31.101远程登录数据库

grant all on *.* to 'root'@'192.168.31.101' identified by '123456' with grant option (授权为超级用户)

mysql -uroot -h192.168.31.101 -P3306 -p123456

mysql -uroot -S /tmp/mysql.sokt

mysql的备份与恢复

库备份命令

mysqldump -uroot -p123456 discuz > /www/mysql_bak/discuz.sql

库恢复命令

mysql -uroot -p123456 discuz < /www/mysql_bak/discuz.sql

表备份命令

mysqldump -uroot -p123456 discuz pre_forum_post > /www/mysql_bak/pre_forum_post.sql

表恢复命令

mysql -uroot -p123456 discuz < /www/mysql_bak/pre_forum_post.sql

指定字符集备份恢复

mysqldump -uroot --default-character-set=utf8 -p123456 discuz > /www/mysql_bak/discuz.sql

mysql -uroot --default-character-set=utf8 -p123456 discuz < /www/mysql_bak/pre_forum_post.sql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值