[root@Rocky8-11 ~]# yum repolist repo id repo name appstream Rocky Linux 8 - AppStream baseos Rocky Linux 8 - BaseOS epel Extra Packages for Enterprise Linux 8 - x86_64 extras Rocky Linux 8 - Extras mysql-connectors-community MySQL Connectors Community mysql-tools-community MySQL Tools Community mysql80-community MySQL 8.0 Community Server
[root@Rocky8-11 ~]# yum search mysql-server Last metadata expiration check: 21:29:53 ago on Sat 06 May 2023 04:36:41 PM CST. ========= Name Exactly Matched: mysql-server ========= mysql-server.x86_64 : The MySQL server and related files
[root@Rocky8-11 ~]# grep password /var/log/mysql/mysqld.log 2023-04-27T12:31:35.953177Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
[root@Rocky8-11 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 8 Server version: 8.0.30 Source distribution
Copyright (c) 2000, 2022, 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'forhelp. Type '\c' to clear the current input statement.
mysql> status -------------- mysql Ver 8.0.30 for Linux on x86_64 (Source distribution)
Connection id: 8 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 8.0.30 Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8mb4 Db characterset: utf8mb4 Client characterset: utf8mb4 Conn. characterset: utf8mb4 UNIX socket: /var/lib/mysql/mysql.sock Binary data as: Hexadecimal Uptime: 6 min 7 sec
Threads: 2 Questions: 5 Slow queries: 0 Opens: 120 Flush tables: 3 Open tables: 36 Queries per second avg: 0.013 --------------
4、修改密码
方法一:
1 2 3 4
mysql> alter user root@'localhost' identified by '123456'; Query OK, 0 rows affected (0.00 sec)
mysql>
方法二:
1 2 3
[root@Rocky8-11 ~]# mysqladmin -uroot -p'123456' password '654321' mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
用新密码登录mysql:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
[root@Rocky8-11 ~]# mysql -uroot -p654321 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 Server version: 8.0.30 Source distribution
Copyright (c) 2000, 2022, 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'forhelp. Type '\c' to clear the current input statement.
[root@Rocky8-12 ~]# yum search MariaDB-server MariaDB 224 kB/s | 483 kB 00:02 Last metadata expiration check: 0:00:01 ago on Sun 07 May 2023 02:53:17 PM CST. ========= Name Exactly Matched: MariaDB-server ========= MariaDB-server.x86_64 : MariaDB database server binaries ============= Name & Summary Matched: MariaDB-server ========== MariaDB-server-debuginfo.x86_64 : Debug information for package MariaDB-server ========== Name Matched: MariaDB-server ========== mariadb-server.x86_64 : The MariaDB server and related files mariadb-server-galera.x86_64 : The configuration files and scripts for galera replication mariadb-server-utils.x86_64 : Non-essential server utilities for MariaDB/MySQL applications
[root@Rocky8-12 ~]# mysql Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 10.11.2-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h'forhelp. Type '\c' to clear the current input statement.
MariaDB [(none)]> MariaDB [(none)]> status -------------- mysql Ver 15.1 Distrib 10.11.2-MariaDB, for Linux (x86_64) using readline 5.1
Connection id: 3 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server: MariaDB Server version: 10.11.2-MariaDB MariaDB Server Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: latin1 Db characterset: latin1 Client characterset: utf8mb3 Conn. characterset: utf8mb3 UNIX socket: /var/lib/mysql/mysql.sock Uptime: 1 min 15 sec
Threads: 1 Questions: 4 Slow queries: 0 Opens: 17 Open tables: 10 Queries per second avg: 0.053 --------------
[root@Rocky8-11 ~]# mysqladmin -uroot -p'su,V+SoSl1uj' password 123456 mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety.
[root@Rocky8-11 ~]# mysql -uroot -p123456 mysql: [Warning] Using a password on the command line interface can be insecure. Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 8.0.33 MySQL Community Server - GPL
Copyright (c) 2000, 2023, 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'forhelp. Type '\c' to clear the current input statement.