亚洲国产第一_开心网五月色综合亚洲_日本一级特黄特色大片免费观看_久久久久久久久久免观看

Hello! 歡迎來到小浪云!


入門MySQL數據庫導入與導出及重置root密碼


avatar
小浪云 2024-10-25 217

入門MySQL數據庫導入與導出及重置root密碼

如何導入和導出數據庫

要導出數據庫,打開終端,確保您未登錄mysql并鍵入,

 mysqldump -u [username] -p [database name] > [database name].sql  
登錄后復制

您在命令中選擇的數據庫現在將導出到您的Droplet。

要導入數據庫,首先在mysql shell中創建一個新的空白數據庫作為數據的目標。

 CREATE DATABASE newdatabase;  
登錄后復制

然后注銷mysql shell,并在命令行中鍵入以下命令

 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 
登錄后復制

這樣,您選擇的數據庫已導入到mysql中的目標數據庫。

如何重置root密碼

當您首次安裝mysql時,您必須設置root密碼。但是,如果你忘記它在任何時候,你仍然可以恢復它。

第一步 – 關閉mysql

在終端中,停止mysql進程

  /etc/init.d/mysql stop 
登錄后復制
第二步 – 訪問mysql安全模式

在安全模式下,您將能夠在mysql系統中單獨使用root密碼進行更改,而無需mysql root密碼。

 sudo mysqld_safe --skip-grant-tables &  
登錄后復制

一旦安全模式啟動,登錄mysql并提示,使用您的標準root密碼。

 mysql -u root mysql 
登錄后復制
第三步 – 設置新密碼

最后,通過鍵入以下命令設置新的mysql root密碼。將“newpassword”替換為您選擇的密碼。

 update user set password=PASSWORD("newpassword") where User='root'; 
登錄后復制

一定要重新加載一切:

  FLUSH PRIVILEGES;  
登錄后復制

并且您現在有一個新的root密碼。

相關閱讀