標籤:and mysq creat 備份 tab .sql rom style where
Database Backup: mysqldump -u user_name -p password database_name >file_name.sql 資料庫還原: 法一: ① 建立資料庫: ② 還原:mysql -u user_name -p password database_name < file_name.sql(全路徑) 法二: 還原:source file_name.slq(全路徑) 將資料庫還原到當前資料庫 建立使用者:(必須在root中才能建立使用者) 法一: create user ‘user_name‘@‘localhost‘ identified by ‘password‘; 法二:直接操作user表 insert into mysql.user(Host,User,authentication_string,ssl_cipher,x509_issuer,x509_subject) values (‘localhost‘,‘user_name‘,PASSWORD(‘password‘),‘‘,‘‘,‘‘); 操作以後必須 flush privileges 刪除使用者: 法一: drop user ‘user_name‘@‘localhost‘; 法二:直接操作user表 delete from mysql.user where host=‘localhost‘ and user=‘user_name‘; 刪除以後必須flush privileges(重新整理許可權) 修改使用者密碼: 法一: mysqladmin -u user_name -pold_password password new_password; 法二:要先登入使用者 set password=new_password; 在root使用者登入的時候 法三:先登入root使用者,直接操作user表中的authentication欄位來修改密碼 update mysql.user set authentication_string=PASSWORD(‘password‘) where host=‘localhost‘ and user=‘user_name‘; 法四:普通使用者在登入到目前使用者下,修改當前 set password=password(‘new_password‘); set password for ‘user_name‘@‘localhost‘=password(‘new_password‘); 重新整理: flush privileges;(直接操作user表的都要flush privileges) 每一個使用者資料都是user表中的一條記錄
mysql-備份和恢複