In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "CentOS7 installs MySQL5.7 with yum". Many people will encounter such a dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
MariaDB is installed by default in CentOS, which is a branch of MySQL, but for the sake of need, MySQL is installed on the system, and MariaDB can be overwritten directly after installation.
1 download and install MySQL's official Yum Repository [root@localhost ~] # wget-I-c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
Use the above command to download the installation Yum Repository directly, about what 25KB looks like, and then you can install yum directly.
[root@localhost] # yum-y install mysql57-community-release-el7-10.noarch.rpm
After that, the MySQL server is installed.
[root@localhost ~] # yum-y install mysql-community-server
This step may take some time, and the previous mariadb will be overwritten after the installation is complete.
At this point, the MySQL installation is complete, followed by some settings for MySQL.
2 MySQL database settings
Start MySQL first
[root@localhost ~] # systemctl start mysqld.service
View the running status of MySQL, as shown in the figure:
[root@localhost ~] # systemctl status mysqld.service
Enter the database with the following command:
[root@localhost] # mysql-uroot-p
Enter the initial password, and you can't do anything at this time, because MySQL must change the password by default before you can manipulate the database:
Mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY' new password'
There is a problem here. When setting a new password, an error will be reported if the setting is too simple.
The reason is that MySQL has a specification for password setting, which is specifically related to the value of validate_password_policy:
The complete initial password rules for MySQL can be viewed with the following command:
Mysql > SHOW VARIABLES LIKE 'validate_password%' +-- +-+ | Variable_name | Value | +-- +-+ | validate_password_check_user_ Name | OFF | | validate_password_dictionary_file | | validate_password_length | 4 | validate_password_mixed_case_count | 1 | validate_password_number_count | 1 | validate_password_policy | LOW | | validate_password_special_char_count | 1 | +- -+-+ 7 rows in set (0.01 sec)
The length of the password is determined by validate_password_length, and the formula for validate_password_length is:
Validate_password_length = validate_password_number_count + validate_password_special_char_count + (2 * validate_password_mixed_case_count)
Mine has been modified, and the first value in the initial case is ON,validate_password_length 8. You can modify it with the following command:
Mysql > set global validate_password_policy=0;mysql > set global validate_password_length=1
After the setting, I found out the above values, at this time the password can be set very simple, such as 1234 and so on. The password setting to this database is complete.
However, there is another problem at this time, that is, because Yum Repository is installed, every yum operation will be automatically updated later, and this needs to be uninstalled:
[root@localhost] # yum-y remove mysql57-community-release-el7-10.noarch
It was only then that it was really finished.
Mysql sets root password when you forget your password
After the root password is set, what if you forget the password after you haven't used mysql for a long time? let's move on. At this point, use the vim command or other editor to open the / etc/my.cnf file:
Vim / etc/my.cnf
Then find the [mysqld] section in my.cnf, as shown in the second figure below:
In this area, add the keyword in the following figure:
Skip-grant-tables
Then save the exit.
Restart the mysqld service with the command:
Systemctl restart mysqld
After the restart is completed, you don't need any password. When you log in, you can enter directly to enter the interactive interface of mysql.
Then change the root password, this time in the second format of the modified password:
Update mysql.user set authentication_string=password ("your_password") where user = 'root' and host='localhost'
This command updates the password field of the root@localhost user in the system table. After the update, refresh the system table:
Flush privileges
Exit after refresh
Then comment or delete the keyword on the line in / etc/my.cnf, and restart mysqld. Just use the new password you just set when you log in.
This is the end of the content of "CentOS7 installs MySQL5.7 in yum". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.