Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Linux changes the password of mysql

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

I installed mysql-server in the centos6.8 container of docker, but I was not prompted to set the password during the installation, but after installation, I used root users to enter without entering the password, so I need to change the password of mysql.

Mysql-uroot-pmysql > update user set password=PASSWORD ('you password') where user='root'; for example: mysql > update user set password=PASSWORD (' admin123') where user='root';mysql > flush privileges;mysql > exit

After restarting mysql, you can log in with the password you just set.

If mysql sets the password but forgets it, you need to reset the password like this

First find the my.conf file of mysql, and add skip-grant-tables under [mysqld]. Skip password verification, and you can log in to mysql without a password.

Vim / etc/my.conf [mysqld] datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sockuser=mysql# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0skip-grant-tables # Skip password authentication [mysqld_safe] log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid

After restarting, you can log in to mysql without a password. After entering, set the password of root according to the above method. After setting it, delete or comment out the fields in the my.conf file that skip password verification, and then restart to log in with the password you just set.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report