前言:
目前各位老铁们对“linux安装应用密码忘记”大概比较着重,同学们都需要学习一些“linux安装应用密码忘记”的相关资讯。那么小编同时在网上网罗了一些有关“linux安装应用密码忘记””的相关资讯,希望兄弟们能喜欢,朋友们一起来了解一下吧!因为要搭建数仓安装hive,而hive的元数据一般是存在mysql数据库,安装后没有保存,后面再去登录就忘记密码了,现在如下处理:
这是修改完成后登录如图:
1、配置免密登录mysql
编辑/etc/my.cnf配置文件
mysqld组加上一行skip-grant-tables
[root@hadoop current]# cat /etc/my.cnf# For advice on how to change settings please see# [mysqld]skip-grant-tables## Remove leading # and set to the amount of RAM for the most important data# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.# innodb_buffer_pool_size = 128M#
2、重启mysqld使其配置生效
systemctl restart mysqld.service
systemctl status mysqld.service
[root@hadoop current]# systemctl status mysqld.service● mysqld.service - MySQL Server Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled) Active: active (running) since Wed 2022-03-16 16:31:37 CST; 2 days ago Docs: man:mysqld(8) Process: 27680 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 27708 (mysqld) Status: "Server is operational" Tasks: 38 CGroup: /system.slice/mysqld.service └─27708 /usr/sbin/mysqldMar 16 16:31:34 192.168.10.248 systemd[1]: Stopped MySQL Server.Mar 16 16:31:34 192.168.10.248 systemd[1]: Starting MySQL Server...Mar 16 16:31:37 192.168.10.248 systemd[1]: Started MySQL Server.
3、mysql清空旧密码
mysql -u root -p //提示输入密码时直接敲回车。
use mysql //选择数据库
update user set authentication_string = ‘’ where user = ‘root’; //将密码置空
quit //退出
[root@hadoop current]#mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.26 MySQL Community Server - GPL
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> 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
mysql> update user set authentication_string = '' where user = 'root';
Query OK, 1 row affected (0.00 sec)
mysql> quit
4、取消my.cnf免密登录并重启mysqld使其配置生效
systemctl restart mysqld.service
5、修改密码
mysql -u root -p //提示输入密码时直接敲回车,刚刚已经将密码置空了
ALTER USER ‘root’@‘localhost’ IDENTIFIED BY ‘Shujuku_@123’
密码形式过于简单则会报错
[root@hadoop current]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 22
Server version: 8.0.26 MySQL Community Server - GPL
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>
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Shujuku_@123';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
再次登录:
[root@hadoop current]# mysql -u root -pEnter password: Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 11Server version: 8.0.26 MySQL Community Server - GPLCopyright (c) 2000, 2021, Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql> showdatabases;ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'showdatabases' at line 1mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.16 sec)mysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> show tables;+------------------------------------------------------+| Tables_in_mysql |+------------------------------------------------------+| columns_priv || component || db || default_roles || engine_cost || func || general_log || global_grants || gtid_executed || help_category || help_keyword || help_relation || help_topic || innodb_index_stats || innodb_table_stats || password_history || plugin || procs_priv || proxies_priv || replication_asynchronous_connection_failover || replication_asynchronous_connection_failover_managed || replication_group_configuration_version || replication_group_member_actions || role_edges || server_cost || servers || slave_master_info || slave_relay_log_info || slave_worker_info || slow_log || tables_priv || time_zone || time_zone_leap_second || time_zone_name || time_zone_transition || time_zone_transition_type || user |+------------------------------------------------------+37 rows in set (0.01 sec)mysql> quitBye[root@hadoop current]#
标签: #linux安装应用密码忘记