2022年9月21日星期三

kali linux mysql init login

service mysql start 
sudo mysql -u root 

MariaDB [(none)]>  show databases

+--------------------+

| Database           |

+--------------------+

| information_schema |

| mysql              |

| performance_schema |

| sys                |

+--------------------+

4 rows in set (0.001 sec)


MariaDB [(none)]> select Host, User, Password  from mysql.user;

+-----------+-------------+----------+

| Host      | User        | Password |

+-----------+-------------+----------+

| localhost | mariadb.sys |          |

| localhost | root        | invalid  |

| localhost | mysql       | invalid  |

+-----------+-------------+----------+

3 rows in set (0.001 sec)

MariaDB [(none)]> use mysql 
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD';
Query OK, 0 rows affected (0.012 sec)

MariaDB [mysql]> exit 
Bye
$ mysql -u root -p 
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 32
Server version: 10.6.8-MariaDB-1 Debian buildd-unstable

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)]> 

When forgot password. to next for reset 

$ service mysql stop  
$ sudo mysqld_safe --skip-grant-tables 
220921 10:31:13 mysqld_safe Logging to syslog.
220921 10:31:13 mysqld_safe Starting mariadbd daemon with databases from /var/lib/mysql

Open a new Terminal
mysql -u root mysql
FLUSH PRIVILEGES;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'NEW_PASSWORD';
FLUSH PRIVILEGES;
quit
sudo kill `sudo cat /var/run/mysqld/mysqld.pid`

没有评论: