mysql指令備忘錄(一)

mysql指令備忘錄(一)

  • 紀錄基本指令
  • 忘記mysql root 解決方法

設定 mysql root密碼

指令 : mysqladmin -u root password ‘1234’
連結資料庫指令
語法 : mysql -h 主機 -U 資料庫使用者帳號 -p 要連接的資料庫名稱
新增資料帳號 :
ex: 新增 roy 帳號 ,密碼設定為 1234 ,且讓roy管理 blog資料庫
1.先利用root連接mysql —> mysql -u root -p mysql
2. 新增帳號,在mysql>提示符號中輸入
grant all privileges on blog.* to roy@localhost identified by ‘1234’;

忘記mysql root 解決方法

1. 關閉 MySQL 伺服器。
service mysqld stop

2. 用以下指令啟動 MySQL,以跳過檢查權限的資料表
mysqld_safe –skip-grant-tables &

3. 現在己經可以用空密碼進入 MySQL
mysql -u root
4. 進入 MySQL 後執行以下指令更改 mysql root 密碼:
mysql> update mysql.user set password=PASSWORD(”new_password”) where User=’root’;
mysql> flush privileges;
mysql> quit

5. 最後只需重新啟動 MySQL,便可以用新設定的密碼進入了。



本篇瀏覽人數: 1613
分類: Mysql篇。這篇內容的永久連結

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *