Yum temporary password for root user after installing MySQL

Source: Internet
Author: User

1. View the root user temporary random password

After Yum installs MySQL, it cannot log in to the database with a blank password, as follows:

1 [[email protected]123 mysql]# mysql-u root-p231045 (28000for'root'@'localhost' ( Using Password:no)

After the lookup, originally in order to increase the security of the database, the installation will generate a temporary random password for the root user, stored in the/var/log/mysqld.log. The root user's temporary password is viewed in the following way (the red callout is its temporary password):

1[[Email protected]123mysql]#grep 'Password'/var/log/mysqld.log |Head-N12  .- .-17T02: on: on.026946Z1[Note] A temporary password is generated for[email protected]: xqwlxlv3p.a8 3[Email protected] mysql]# Mysql-u root-P4 Enter Password:5 Welcome to the MySQL Monitor. Commands End With; or \g.6Your MySQL ConnectionIDIs311697Server version:5.7. -
2. Change the root user password

When you log in to the database using a temporary password, MySQL will prompt you to modify the temporary password, otherwise it cannot be used, as follows:

1 mysql> show databases; 2 1820 (HY000): Must reset your password using ALTER USER statement before executing this statement.

Modify the user using the ALTER USER command: (I am not using it, I enclose the link here for easy viewing later)

http://blog.csdn.net/ziwen00/article/details/8460754

The ALTER user format is as follows:

alter user [user name] indentified by [New password];

To change the root password, use the following method, three steps to complete the password password changes:

Mysql> Set Password ('123455');       #红色部分是新密码
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#提示信息: The password does not meet the requirements of the current password policy, the specific principle is not described here, you can see the installation MySQL5.6 new user and create a password always prompt password does not meet the requirements: ERROR 1819 (HY000): Your password does not. Solve
#解决方法: Here we can refer to the format of the password generated for the root user "uppercase and lowercase letters + numbers-Special symbols"
Mysql> ALTER USER ' root ' @ ' localhost ' PASSWORD EXPIRE never;
Query OK, 0 rows Affected (0.00 sec)

mysql> flush Privileges;
Query OK, 0 rows Affected (0.00 sec)

You can log on to the database by using the new password.

3. Configure remote connections for the database
1Mysql>create USER'Root'@'%'Identified by'Your password';2# Add root user specified can be any IP login, if you want to limit only let the specified IP login please put%Replace with IP address3    4Mysql>grant all privileges on *. * To'Root'@'%'Identified by'your password.'With GRANT OPTION Max_queries_per_hour0Max_connections_per_hour0Max_updates_per_hour0Max_user_connections0 ;5#给新添加的root增加权限

  

Yum temporary password for root user after installing MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.