《MySQL常用操作》要點(diǎn):
本文介紹了MySQL常用操作,希望對(duì)您有用。如果有疑問,可以聯(lián)系我們。
創(chuàng)建mysql用戶和數(shù)據(jù)表
create database testcom;
grant all on testcom.* to 'cxf'@'localhost' identified by 'cxf';
MySQL的密碼重置
設(shè)置root密碼為123456
mysql -uroot password '123456'
vim /etc/my.cnf
在最后面加一條
skip-grant
不去授權(quán)
登錄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
授權(quán)192.168.31.101遠(yuǎn)程登錄數(shù)據(jù)庫
grant all on *.* to 'root'@'192.168.31.101' identified by '123456' with grant option (授權(quán)為超級(jí)用戶)
mysql -uroot -h192.168.31.101 -P3306 -p123456
mysql -uroot -S /tmp/mysql.sokt
mysql的備份與恢復(fù)
庫備份命令
mysqldump -uroot -p123456 discuz > /www/mysql_bak/discuz.sql
庫恢復(fù)命令
mysql -uroot -p123456 discuz < /www/mysql_bak/discuz.sql
表備份命令
mysqldump -uroot -p123456 discuz pre_forum_post > /www/mysql_bak/pre_forum_post.sql
表恢復(fù)命令
mysql -uroot -p123456 discuz < /www/mysql_bak/pre_forum_post.sql
指定字符集備份恢復(fù)
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
歡迎參與《MySQL常用操作》討論,分享您的想法,維易PHP學(xué)院為您提供專業(yè)教程。
轉(zhuǎn)載請(qǐng)注明本頁網(wǎng)址:
http://www.fzlkiss.com/jiaocheng/7156.html