close

參考文獻:https://www.mdeditor.tw/pl/pw03/zh-tw

# sudo apt-get update

# apt-get install mysql-server, mysql-client, libmysqlclient-dev(C語言相關庫)

安裝Mysql Secure

# sudo mysql_secure_installation

# mysql

mysql> use mysql

mysql> update user set quthentication_string='' where user='root';

mysql> alter user 'root'@'localhost' identified with mysql_native_password by 'Xxxx-2222';
Query OK, 0 rows affected (0.03 sec)

↑修改root的密碼。

以下是新增使用者和他們的密碼:

mysql> create user 'steventsai'@'localhost' identified by 'Xxxx-1111';
Query OK, 0 rows affected (0.03 sec)

mysql> grant all privileges on *.* to 'steventsai'@'localhost';
Query OK, 0 rows affected (0.03 sec)

(base) cltai@rdwks:~$ mysql -u steventsai -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 20
Server version: 8.0.23-0ubuntu0.20.04.1 (Ubuntu)

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

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>

就可以讓新的使用者有所有的權限。

 

arrow
arrow
    文章標籤
    ubuntu mysql install 安裝
    全站熱搜
    創作者介紹
    創作者 貓熊麗麗 的頭像
    貓熊麗麗

    片刻、瞬間、不知所云...

    貓熊麗麗 發表在 痞客邦 留言(0) 人氣()