Tencent cloud host mysql initial password change

The system purchased on Tencent Cloud has already installed the mysql database. Generally speaking, the password of the default root user is empty, but it is found that the initial password is not empty, so I try to change the initial password.

 

First log in to the server, find the my.cnf file, which is usually in the /etc directory (if not, you can use the find / -name my.cnf command to find it), and then use the vi my.cnf command to edit the file (it is recommended to back it up first) , add skip-grant-tables below [ mysqld ] .

The function is to skip login authentication when logging in, in other words, root can log in with any password, and then : wq save and exit, restart mysql with service mysqld restart .

 

Next, enter the following command in Linux :

mysql -uroot -p

mysql> use mysql; 
mysql> update user set password=password('123') where user='root'; 
mysql> flush privileges; 

 

exit mysql

remove skip-grant-tables

Restart mysql and finish.

 

Transfer: http://blog.csdn.net/daijiguo/article/details/52717862

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326390584&siteId=291194637