首先,在操作前一定要记得先备份数据库或数据表。
备份之后,网上搜索到的使用mysqldump的方法如下:
备份表:
mysqldump -u user -p database_name table_name > table_name.sql
还原表:
mysqldump -u user -p database_name table_name < table_name.sql
此时查看table_name.sql就可发现,其中包含语句DROP TABLE IF EXISTS `user`;
说明会覆盖原来的user表,所以最好不要这样操作。
有一个不是办法的办法是将table_name.sql中的sql语句拿到新数据库中执行一遍。
假如不小心将数据表覆盖了,那么plesk面板登录会出现问题,官网上找到的解决办法如下:
Cause
The password in the file /etc/psa/.psa.shadow
, which is used to access the Plesk database, does not match your admin password.
OR
The old-passwords=1
option is enabled in /etc/my.cnf
.
Resolution
-
Make sure that option
old-passwords = 1
is disabled in the/etc/my.cnf
file. -
Obtain the correct Plesk password:
# cat /etc/psa/.psa.shadow $AES-128-CBC$XIhAAAAAAAAAA+tw==$85FWOUmg8AAAAAAAAAg==
-
Try to connect to the MySQL database and update the admin password:
# mysql -uadmin -p`cat /etc/psa/.psa.shadow` psa mysql> UPDATE mysql.user SET Password=PASSWORD('$AES-128-CBC......') WHERE User='admin';
Note: If you are unable to connect, enable
skip-grant-tables
in the/etc/my.cnf
file, restart MySQL, then update the admin password:[mysqld] skip-grant-tables # /etc/init.d/mysqld restart # mysql -uadmin mysql> UPDATE mysql.user SET Password=PASSWORD('$AES-128-CBC......') WHERE User='admin';
Note: do not forget to remove
skip-grant-tables
after that. -
Update the password for Plesk using the
ch_admin_passwd
utility:# /usr/local/psa/bin/admin --show-password password # export PSA_PASSWORD=password # /usr/local/psa/admin/bin/ch_admin_passwd