Home  >  Article  >  Database  >  Share 3 ways to set passwords for Mysql installation-free version

Share 3 ways to set passwords for Mysql installation-free version

零下一度
零下一度Original
2017-05-04 13:29:301543browse

This article mainly introduces Mysqldetailed tutorial on setting the password for the installation-free version. Friends who need it can refer to

Method 1: Use the SET PASSWORD command

 MySQL -u root
  mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('newpass');

Method 2: Use mysqladmin

mysqladmin -u root password "newpass"

If root has already set a password, use the following method

mysqladmin -u root password oldpass "newpass"

Method 3: Use UPDATE directly Edit the user table

mysql -u root
  mysql> use mysql;
  mysql> UPDATE user SET Password = PASSWORD('newpass') WHERE user = 'root';
  mysql> FLUSH PRIVILEGES;

When you lose the root password, you can do this

mysqld_safe --skip-grant-tables&
  mysql -u root mysql
  mysql> UPDATE user SET password=PASSWORD("new password") WHERE user='root';
  mysql> FLUSH PRIVILEGES;

The above is the detailed explanation of the password setting tutorial for the Mysql installation-free version introduced by the editor. I hope it will be helpful to you. This is helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time!

【Related recommendations】

1. Free mysql online video tutorial

2. MySQL latest manual tutorial

3. Six days to take you through MySQL video tutorial

The above is the detailed content of Share 3 ways to set passwords for Mysql installation-free version. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn