pkill mysqld 關(guān)閉掉Mysql
跳過(guò)MYSQL的權(quán)限表啟動(dòng)MySQL服務(wù):
–skip-grant-tables啟動(dòng)mysql
/usr/local/mysql8013/bin/mysqld_safe --defaults-file=/data/mysql8/my8.cnf --skip-grant-tables &
將密碼置空:
root@localhost [(none)]>update mysql.user set authentication_string=\\\'\\\' where user=root and host=localhost;
Query OK, 1 row affected (0.06 sec)
Rows matched: 1 Changed: 1 Warnings: 0
root@localhost [(none)]>
pkill mysqld 關(guān)閉掉mysql
再次啟動(dòng)mysql服務(wù)
[root@localhost ~]# /usr/local/mysql8013/bin/mysqld --defaults-file=/data/mysql8/my8.cnf &
無(wú)密碼登錄MySQL服務(wù)并設(shè)置新的密碼:
root@localhost [(none)]>select version();
-----------
| version() |
-----------
| 8.0.13 |
-----------
root@localhost [(none)]>alter user user() identified by \\\'jist558@wei\\\';
[root@localhost ~]# mysql -uroot -p\\\’jist558@wei\\\’ -e "select version();"
mysql: [Warning] Using a password on the command line interface can be insecure.
———–
| version() |
———–
| 8.0.13 |
———–
密碼寫入.my.cnf文件就可以mysql直接登錄mysql窗口:
[root@localhost ~]# cat .my.cnf
[mysql]
prompt=\\\\u@\\\\h:\\\\p \\\\R:\\\\m:\\\\s[\\\\d]>
no-auto-rehash
user=root
password=jist558@wei
[root@localhost ~]# mysql -e select version();
-----------
| version() |
-----------
| 8.0.13 |
-----------
演示完畢
更多關(guān)于云服務(wù)器,域名注冊(cè),虛擬主機(jī)的問(wèn)題,請(qǐng)?jiān)L問(wèn)西部數(shù)碼官網(wǎng):www.ps-sw.cn