当前位置:网站首页>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
边栏推荐
猜你喜欢
数据库上机实验7 数据库设计
vulhub靶场学习日记SickOs1.2
Linux中mysql密码修改方法(亲测可用)
永恒之蓝漏洞复现
代码块、Package,Import,封装(第六天)
08 【生命周期 组件】
(Crypto essential dry goods) Detailed analysis of the current NFT trading markets
C语言实验三 选择结构程序设计
GUCCI, LV and other luxury giant universe how to layout yuan, other brands should keep up with?
02 【el和data的两种写法 MVVM模型】
随机推荐
字符串的新增方法
NFT与数字藏品到底有何区别?
C语言实验五 循环结构程序设计(二)
gin框架学习-GORM框架进阶之CRUD接口(数据库增删改查操作)
继承、Super,重写、抽象类、抽象方法 1(第七天)
Swordsman Offer Special Assault Edition ---- Day 6
MySql创建数据表
Error: Cannot find module ‘D:\Application\nodejs\node_modules\npm\bin\npm-cli.js‘
数据库上机实验6 数据库完整性
mac10.14中安装mysqldb
gin框架学习-Gin框架和Gorm框架搭建一个简单的API微服务
[JVM Loading]---Class Loading Mechanism
leetcode-1833. 雪糕的最大数量(排序+贪心)
局部变量成员变量、引用类型、this,static(第五天)
C language tutorial (1) - preparation
npm WARN config global `--global`, `--local` are deprecated. Use `--location解决方案
初识正则表达式
联盟链的真实场景在哪里
02 【el和data的两种写法 MVVM模型】
PHP中abstract(抽象)、final(最终)和static(静态)原理与用法