如何導(dǎo)入和導(dǎo)出數(shù)據(jù)庫
要導(dǎo)出數(shù)據(jù)庫,打開終端,確保您未登錄mysql并鍵入,
mysqldump -u [username] -p [database name] > [database name].sql
登錄后復(fù)制
您在命令中選擇的數(shù)據(jù)庫現(xiàn)在將導(dǎo)出到您的Droplet。
要導(dǎo)入數(shù)據(jù)庫,首先在mysql shell中創(chuàng)建一個新的空白數(shù)據(jù)庫作為數(shù)據(jù)的目標(biāo)。
CREATE DATABASE newdatabase;
登錄后復(fù)制
mysql -u [username] -p newdatabase With that, your chosen database has been imported into your destination database in MySQL. How to Reset a Root Password When you first install MySQL, you have to set up your root password. However, should you forget it at any point, you can still recover it. Step One—Shut Down MySQL In terminal, stop the MySQL process /etc/init.d/mysql stop Step Two—Access MySQL Safe Mode In safe mode, you will be able to make changes within the MySQL system with a root password alone, without the need for MySQL root password. sudo mysqld_safe --skip-grant-tables & Once safe mode has started up, log into MySQL and when prompted, use your standard root password. mysql -u root mysql Step Three—Set Up a New Password Finally, set up the new MySQL root password by typing the command below. Replace "newpassword" with the password of your choice. update user set password=PASSWORD("newpassword") where User='root'; Be sure to reload everything: FLUSH PRIVILEGES; and you now have a new root password. By Etel Sverdlov
登錄后復(fù)制
這樣,您選擇的數(shù)據(jù)庫已導(dǎo)入到mysql中的目標(biāo)數(shù)據(jù)庫。
如何重置root密碼
當(dāng)您首次安裝mysql時,您必須設(shè)置root密碼。但是,如果你忘記它在任何時候,你仍然可以恢復(fù)它。
第一步 – 關(guān)閉mysql
在終端中,停止mysql進程
/etc/init.d/mysql stop
登錄后復(fù)制
第二步 – 訪問mysql安全模式
在安全模式下,您將能夠在mysql系統(tǒng)中單獨使用root密碼進行更改,而無需mysql root密碼。
sudo mysqld_safe --skip-grant-tables &
登錄后復(fù)制
一旦安全模式啟動,登錄mysql并提示,使用您的標(biāo)準(zhǔn)root密碼。
mysql -u root mysql
登錄后復(fù)制
第三步 – 設(shè)置新密碼
最后,通過鍵入以下命令設(shè)置新的mysql root密碼。將“newpassword”替換為您選擇的密碼。
update user set password=PASSWORD("newpassword") where User='root';
登錄后復(fù)制
一定要重新加載一切:
FLUSH PRIVILEGES;
登錄后復(fù)制
并且您現(xiàn)在有一個新的root密碼。