《MySQL常用操作》要點:
本文介紹了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
歡迎參與《MySQL常用操作》討論,分享您的想法,維易PHP學院為您提供專業教程。
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/7156.html