Table of Contents
1.Download
2. Uninstall
3.Installation
4.Connect
1.Download
Official website address: https://dev.mysql.com/downloads/mysql/5.7.html
Download results
cd /usr/local
mkdir mysql
rz Upload the downloaded mysql package to the new /usr/local/mysql in linux
upload completed
2.Uninstall
Clear pre-installed mariadb or mysql
1. Query the installed mariadb and mysql
rpm -aq|grep -i mariadb;
rpm -aq|grep -i mysql;
2. Uninstall mariadb and mysql
yum erase -y mariadb-libs-5.5.68-1.el7.x86_64;
or rpm -e –nodeps mariadb-libs-5.5.68-1.el7.x86_64;
These two commands have the same effect and are used to uninstall the package named “mariadb-libs-5.5.68-1.el7.x86_64”. However, they are implemented slightly differently.
-
yum erase -y mariadb-libs-5.5.68-1.el7.x86_64;
uses theyum
command, which is a package manager for managing packages and software . Theyum erase
command is used to uninstall the specified software package. The-y
parameter is used to automatically answer the “yes” confirmation prompt to avoid stopping and waiting for the user during execution. confirm. -
rpm -e --nodeps mariadb-libs-5.5.68-1.el7.x86_64;
uses therpm
command, which is a tool for managing RPM (Red Hat Package Manager) package’s command line tools. Therpm -e
command is used to uninstall the specified software package. The--nodeps
parameter is used to specify the option to ignore dependencies, that is, not to check and uninstall the dependencies of the software package. .
Overall, these two commands aim to achieve the same goal, but they use different tools and parameters to achieve their effects. Which command you choose depends on your needs and personal preference. If you are using CentOS or other RPM-based Linux distributions, it is recommended to use the yum erase
command to manage software packages.
3. After the uninstallation is complete, query the installed mariadb and mysql again.
rpm -aq|grep -iE ‘mariadb|mysql’;
An empty query indicates that the uninstallation is complete.
4. Find database residual files
find/-name mysql;
find / -name my.cnf;
If you can find the following two msyql data storage directories and configuration files, you need to delete them
/var/lib/mysql
/etc/my.cnf
3.Installation
1. Decompress
2. Install the server
rpm -ivh mysql-community-server-5.7.44-1.el7.x86_64.rpm –force –nodeps
When installing MySQL in rpm mode under Linux, I encountered warning: mysql-community-server-5.7.44-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY error. This is because yum installed the old The solution to the problem caused by the version of GPG keys: add –force –nodeps, such as: rpm -ivh mysql-community-server-5.7.44-1.el7.x86_64.rpm –force –nodeps.
3. Install the client
rpm -ivh mysql-community-client-5.7.44-1.el7.x86_64.rpm –force –nodeps
4. Check whether the installation is successful
rpm -aq|grep mysql
5. Start the mysql service
systemctl start mysqld
6. Check whether mysql starts successfully
systemctl status mysqld
4. Enter the database
1. The initialization password is in the mysqld log.
grep ‘temporary password’ /var/log/mysqld.log
)u/Y!FGmr9wJ
2. Enter mysql with the initial password
mysql -uroot -p # )u/Y!FGmr9wJ
3. Reset password, note: the password must contain uppercase and lowercase letters + special characters + numbers
alter user ‘root’@’localhost’ identified by ‘Aa123456.’;
or set password = password(‘Aa123456.’); #Set password, password is a function and requires brackets
4. After exiting the database, re-enter with the password you just reset.
5. Authorize the root account
grant all privileges on *.* to root@'%' identified by 'Aa123456.'; #The password granted to the root user is Aa123456., allowing him to access all files under this database through all clients The library and all tables below it have all permissions. flush privileges; #Refresh privileges
grant all privileges on *.* to ‘root’ @’%’ identified by ‘Aa123456.’ with grant option;
#The password granted to the root user is Aa123456. It is allowed to access all libraries under this database and all tables below it through all clients, with all permissions.
flush privileges; #Refresh privileges
Installation completed
4.Connect
1.
open
3306
The port number
Open port command:
firewall-cmd –zone=public –add-port=3306/tcp –permanentRestart the firewall:
systemctl restart firewalld.service
END
The knowledge points of the article match the official knowledge files, and you can further learn relevant knowledge. Cloud native entry-level skills treeHomepageOverview 17041 people are learning the system