pkill mysqld 關閉掉Mysql
跳過MYSQL的權限表啟動MySQL服務:
–skip-grant-tables啟動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 關閉掉mysql
再次啟動mysql服務
[root@localhost ~]# /usr/local/mysql8013/bin/mysqld --defaults-file=/data/mysql8/my8.cnf &
無密碼登錄MySQL服務并設置新的密碼:
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 |
-----------
演示完畢
更多關于云服務器,域名注冊,虛擬主機的問題,請訪問三五互聯官網:m.shinetop.cn