[root@server mysql]# service mysqld start
Starting mysqld (via systemctl): [ OK ]
[root@server mysql]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.6.8-MariaDB Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| test |
+--------------------+
5 rows in set (0.001 sec)
7、修改root用户密码
MariaDB [mysql]> select Host,User,Password,authentication_string from user; # 查看当前的用户情况
+-----------+-------------+----------+-----------------------+
| Host | User | Password | authentication_string |
+-----------+-------------+----------+-----------------------+
| localhost | mariadb.sys | | |
| localhost | root | invalid | invalid |
| localhost | mysql | invalid | invalid |
| localhost | | | |
| server | | | |
+-----------+-------------+----------+-----------------------+
5 rows in set (0.001 sec)
MariaDB [mysql]> grant all privileges on *.* to 'root'@'%' identified by '123456'; # 修改用户密码和权限
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]> grant all privileges on *.* to 'root'@'localhost' identified by '123456'; # 修改用户密码和权限
Query OK, 0 rows affected (0.001 sec)
MariaDB [mysql]> select Host,User,Password,authentication_string from user;
+-----------+-------------+-------------------------------------------+-------------------------------------------+
| Host | User | Password | authentication_string |
+-----------+-------------+-------------------------------------------+-------------------------------------------+
| localhost | mariadb.sys | | |
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost | mysql | invalid | invalid |
| localhost | | | |
| server | | | |
| % | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+-----------+-------------+-------------------------------------------+-------------------------------------------+
6 rows in set (0.001 sec)