In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The default database for CentOS7 is mariadb, but many of them use mysql, but there seems to be no mysql in CentOS7's yum source by default.
In the previous article, I installed 5.6. but I think the yum installation of 5.7was the easiest to try to compile and install various problems, and finally decided to use yum.
(after a period of study, I wrote another article to install mysql5.7.22 with source code. Click to open the link.)
1. Uninstall first stop the mysql process that has not been installed. You can skip it directly.
Pkill-9 mysqld rpm-qa | grep-I mysql
Use the command yum-y remove
Yum-y remove mysql-community-client-5.6.38-2.el7.x86_64
Use rpm-ev if you can't uninstall it.
Uninstall in turn until there is no
two。 Download the repo source of mysql to correct the installation of mysql5.7.20 / *, this source downloads the latest version * * /
[root@localhost ~] # cd / usr/local/src/ [root@localhost src] # wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm [root@localhost src] # rpm-ivh mysql57-community-release-el7-8.noarch.rpm [root@localhost src] # yum-y install mysql-server
(you can also specify the installation directory yum-- installroot=/usr/local/mysql-- releasever=/-y install mysql-server) I didn't try, so you don't have to worry about the configuration of environment variables, just install it and start it directly. The installation path is the default.
All the way y
Just follow the steps to install it.
Default profile path:
Configuration file: / etc/my.cnf
Log file: / var/log/var/log/mysqld.log
Service startup script: / usr/lib/systemd/system/mysqld.service
Socket file: / var/run/mysqld/mysqld.pid
Configure my.cnf vim / etc/my.cnf
[mysqld] # # Remove leading # and set to the amount of RAM for the most important data # cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%. # innodb_buffer_pool_size = 128m # # Remove leading # to turn on a very important data integrity option: logging # changes to the binary log between backups. # log_bin # # Remove leading # to set options mainly useful for reporting servers. # The server defaults are faster for transactions and fast SELECTs. # Adjust sizes as needed, experiment to find the optimal values. # join_buffer_size = 128m # sort_buffer_size = 2m # read_rnd_buffer_size = 2m datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock server_id = 1 expire_logs_days = 3 # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
However, after the installation, the password is a random password and needs to be reset.
4. Start the mysql service
Service mysqld restart
Reset password
[root@localhost ~] # grep "password" / var/log/mysqld.log
You can see that entering the mysql-u root-p password to log in for the first time, you need to reset the password or nothing can be done.
Next, reset the password: 5.7.20 for security, the password must contain numeric alphanumeric symbols.
Stepped on the pit, ah, set up several times. And the ip can't be%. I don't know why I set it to% for the first time. I can change it after I failed to log on.
A simple way to change the password https://www.jb51.net/article/150472.htm
Alter user 'root'@'localhost' identified by' rootstocks 2018
Finally, remember to refresh permissions.
Flush privileges
You can also add new users directly.
CREATE USER 'root'@'%' IDENTIFIED BY' your password; grant all on *. * to 'root001'@'%' identified by' Root@@' with grant option
Add root users to specify that you can log in to any IP. If you want to restrict only the specified IP login, please replace% with the IP address.
Problem: if you find that you can't find the password!
Solution: the password can only be changed by forgetting the password! It was found that the password could not be found during installation. After a long time of changing the password, we found that the previously installed database was there, and there was no production of the new database! Using the same configuration as before.
two。 See if the mysql is activated? Have you initialized the database yet? Generally, if you start the database directly, you can use grep "password" / var/log/mysqld.log to see the random password.
Modify the login settings for MySQL:
# vi / etc/my.cnf
Add a sentence to the paragraph of [mysqld]: skip-grant-tables saves and exits vi.
Restart mysqld
Restart mysqld # / etc/init.d/mysqld restart (service mysqld restart) use mysql update user set password=password ("12345") where user= "root"; the database of mysql 5.7 without the password field uses the authentication_string field mysql > update mysql.user set authentication_string=password ('root') where user='root'; flush privileges
Change the password and then change it back.
Summary
The above is the easiest way to install MySQL5.7.20 with yum under CentOS 7 introduced by the editor. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support to the website!
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.