mysql 修改root密碼,分配許可權

2021-09-01 16:41:03 字數 2101 閱讀 9741

1.如我的mysql 安裝在e:\xampp\mysql目錄下

win7下使用cmd,命令列使用無密碼的root使用者登入mysql資料庫,紅色字型為命令

1).更新root使用者密碼為root

2.)重新整理許可權

3).分配root使用者在任何主機上都可以訪問mysql資料庫

4).重新整理許可權

e:\xampp\mysql\bin>mysql -uroot -p

enter password:

welcome to the mysql monitor.  commands end with ; or \g.

your mysql connection id is 41

server version: 5.5.25a mysql community server (gpl)

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql> update mysql.user set password=password('root') where user='root';

query ok, 2 rows affected (0.00 sec)

rows matched: 2  changed: 2  warnings: 0

mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

mysql> grant all privileges on *.* to 'root'@'%'

identified by 'root' with grant

option;

query ok, 0 rows affected (0.00 sec)

mysql> flush privileges;

query ok, 0 rows affected (0.00 sec)

mysql> \q

bye2.使用修改過得root使用者密碼root登入mysql

e:\xampp\mysql\bin>mysql -uroot -p

enter password: ****

welcome to the mysql monitor.  commands end with ; or \g.

your mysql connection id is 42

server version: 5.5.25a mysql community server (gpl)

oracle is a registered trademark of oracle corporation and/or its

affiliates. other names may be trademarks of their respective

owners.

type 'help;' or '\h' for help. type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| database           |

+--------------------+

| information_schema |

| cdcol              |

| mysql              |

| oms                |

| performance_schema |

| phpmyadmin         |

| test               |

| webauth            |

+--------------------+

8 rows in set (0.00 sec)

mysql>

MySQL修改root密碼

整理了以下四種在mysql中修改root密碼的方法,可能對大家有所幫助 方法1 用set password命令 mysql u root mysql set password for root localhost password newpass 特別注意 此處的password關鍵字是對後面 ne...

mysql修改root密碼

修改mysql初始化密碼 連線mysql mysql u root p123456 enter password設定密碼 set password for root localhost password 123456 刪除mysql密碼校驗 預設不能使用簡單密碼 mysql set global v...

mysql修改root密碼

忘記mysql的root密碼的情況下,重置root密碼!system centos mysql version 5.0 5.5 1.停掉mysql service mysqld stop 2.配置檔案 etc my.cnf中 mysqld 下 新增 skip grant tables 3.啟動mys...