CentOS 7.4 Method for manually installing MySQL 5.7
- 2021-12-12 10:14:01
- OfStack
MySQL databases are widely used, especially for JAVA programmers. If you don't want to purchase a cloud database, you can install your own MySQL database. This article describes how to manually install MySQL version 5.7 in an CentOS 7.4 environment.
1. Install MySQL version: 5.7. 25
2. Download address
https://dev.mysql.com/downloads/mysql/5.7.html#downloads
(As time goes by, please refer to the latest download address.)
3. Download relevant rpm files by using wget command and breakpoint transmission
(If the address is updated, please refer to the latest)
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.25-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.25-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-devel-5.7.25-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.25-1.el7.x86_64.rpm
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.25-1.el7.x86_64.rpm
4. After downloading, enter the corresponding directory and install it in turn
(Note: Installation has a sequence, just install according to the download sequence above)
rpm -ivh mysql-community-server-5.7.25-1.el7.x86_64.rpm --force --nodeps
(Note: Among them--force--nodeps should be added appropriately according to the situation. Otherwise, some machines will be installed abnormally)
5. After the installation is completed, the service needs to be started first.
(Note that service startup for CentOS 7 and above is different from 6.)
systemctl start mysqld
6. Confirm that the installation is successful and create the initial root administrator password
Revision/etc/my. cnf
vi /etc/my.cnf
Add in [mysqld]
skip-grant-tables=1
This 1-line configuration allows mysqld to start without password verification
7. Restart mysqld service
systemctl restart mysqld
8. Modify the login password of root
1) User login to mysql using root
mysql -uroot -p ( Click Enter directly, and the password is empty )
2) Switch databases
use mysql;
3) Update the user table
update user set authentication_string = password(' Your password '), password_expired = 'N', password_last_changed = now() where user = 'root';
9. After the password is successfully modified, you can log in to mysql to set up the client connection.
(Note: If it is not set, the client Navicat cannot be connected)
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY ' Your password ' WITH GRANT OPTION;
FLUSH PRIVILEGES;
Refresh table data
flush privileges;
Quit
systemctl start mysqld
0
10. Edit the file /etc/my.cnf and delete the contents of skip-grant-tables=1
systemctl start mysqld
1
11. Set the code of MySQL to prevent garbled code. Add the code mode under [mysqld]
systemctl start mysqld
2
(See the attachment document for details)
12. Restart MySQL service
systemctl restart mysqld
After you can connect to the database through client software, such as Navicat for MySQL, congratulations, the installation is successful.
"FAQ"
1. Installed under the server CentOS in Hong Kong, the service could not be started.
systemctl start mysqld
4
After in-depth investigation, the reason is that libaio. so.1 is not installed, so install it.
systemctl start mysqld
5