当前位置:网站首页>Linux modify MySQL database password
Linux modify MySQL database password
2022-07-31 05:48:00 【m0_67401499】
1. Modify the database configuration file so that login does not require a password
This operation requires server root account privileges
1.1 Switch the root user of the Linux system
Note: If you are currently using the root account, you do not need to switch again
# su -
1.2 Targeting Profile Location
# locate my.cnf
- 3Use vitool to open configuration file
# vi /etc/my.cnf
Add the "skip password login" code skip-grant-tables below the file content [mysqld], save and exit.
- 4Confirm that the content of the configuration file has been modified
View the contents of the my.cnf configuration file through the cat command.
#cat /etc/my.cnf
2. Restart Mysql service
2.1 In linux, execute the following command to restart the mysql service (the service name may be different and an error will be reported, according to your own mysql service name as the main)
# systemctl restart mysqld
2.2Completion of reboot can be verified by checking status command
# systemctl status mysqld
3. Log in to MySQL again to see if a password is required to log in
3.1 Confirmation that no password is required to log in to MySQL
In Linux enter:
# mysql -uroot -p
– Note: You can log in to MySQL without a password at this time
4.登录数据库, 修改数据库Account password
4.1 Update Password
Syntax: update user set authentication_string=password('new password') where user = 'username';
mysql >update user set authentication_string=password('123456') where user = 'root';
Or:
mysql >SET PASSWORD FOR [email protected] = PASSWORD('123456');
Or:
mysql>SET PASSWORD = PASSWORD('123456');
4.2 Refresh permissions
mysql>flush privileges;
5. Restore profile settings so that login requires a password
Restoring profile settings is basically the same as adding settings.
- Just comment the skip-grant-tables in the content under [mysqld] in /etc/my.cnf.
- Restart the mysql service: systemctl restart mysqld
- Log in to mysql again.
Let me introduce myself first. The editor graduated from Shanghai Jiaotong University in 2013. I worked in a small company and went to big factories such as Huawei and OPPO. I joined Alibaba in 2018, until now.I know that most junior and intermediate java engineers want to upgrade their skills, they often need to explore their own growth or sign up to study, but for training institutions, the tuition fee is nearly 10,000 yuan, which is really stressful.Self-learning that is not systematic is very inefficient and lengthy, and it is easy to hit the ceiling and the technology stops.Therefore, I collected a "full set of learning materials for java development" for everyone. The original intention is also very simple. I hope to help friends who want to learn by themselves but don't know where to start, and at the same time reduce everyone's burden.Add the business card below to get a full set of learning materials
边栏推荐
猜你喜欢
Digital twins will be an important way to enter the "metaverse"
Yuan prospect and four track of the universe
gin框架学习-Casbin进阶之策略管理API使用方法
Why is the redis single-threaded also so fast?
05 【绑定样式 条件渲染 列表渲染】
vulhub靶场学习日记xxe-lab
11 【定位】
【C语言趣味小游戏——猜数字】
数字取证autopsy工具用法
Kubernetes certificate validity period modification
随机推荐
GUCCI、LV等奢侈品巨头如何布局元宇宙的,其他品牌应该跟上吗?
mac10.14中安装mysqldb
leetcode-438. 找到字符串中所有字母异位词(滑动窗口)
继承、Super,重写、抽象类、抽象方法 1(第七天)
第7章 网络层第3次练习题答案(第三版)
Digital twins will be an important way to enter the "metaverse"
数据库上机实验5 数据库安全性
Three-party login using wallet Metamask based on web3.0
数据库上机实验6 数据库完整性
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
let和const命令
数据库上机实验4 数据更新和视图
梳理一下自己常用的快捷键
Fragmented NFT (Fractional NFT)
Swordsman Offer Special Assault Edition ---- Day 6
初涉C语言
三子棋讲解(C语言)
闭包(二)
“档次法”——用于物品体积分布不均匀的01背包问题的求解方法
Access数据库的查询