[root@localhost mysql]# systemctl start mysqld.service [root@localhost mysql]# systemctl status mysqld.service ● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since 三 2020-05-13 11:09:35 CST; 8s ago Docs: man:mysqld(8) http://dev.mysql.com/doc/refman/en/using-systemd.html Process: 16795 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 16829 (mysqld) Status: "Server is operational" CGroup: /system.slice/mysqld.service └─16829 /usr/sbin/mysqld
5月 13 11:09:24 localhost.localdomain systemd[1]: Starting MySQL Server... 5月 13 11:09:35 localhost.localdomain systemd[1]: Started MySQL Server. [root@localhost mysql]# 查看数据库初始的密码:
[root@localhost mysql]# cat /var/log/mysqld.log | grep password 2020-05-13T03:05:16.041238Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: n_t#tk.Z?7)f 使用初始密码登陆数据库:后更改密码:
[root@localhost mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 8 Server version: 8.0.20
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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> mysql> ALTER user 'root'@'localhost' identified with mysql_native_password by '123456'; Query OK, 0 rows affected (0.04 sec)
mysql> exit Bye [root@localhost mysql]# mysql -uroot -p Enter password: Welcome to the MySQL monitor. Commands end with ; or /g. Your MySQL connection id is 9 Server version: 8.0.20 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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> SELECT VERSION; ERROR 1054 (42S22): Unknown column 'VERSION' in 'field list' mysql> SELECT VERSION(); +-----------+ | VERSION() | +-----------+ | 8.0.20 | +-----------+ 1 row in set (0.00 sec)