MySQL as a popular open-source database management system is widely used in various scenarios, Alibaba Cloud provides high available ApsaraDB RDS for MySQL with enhanced MySQL service is now supporting businesses fighting Coronavirus COVID-19.
The MariaDB database management system is a branch of MySQL, which is mainly maintained by the open source community and is licensed under the GPL. One of the reasons for the development of this branch is that after Oracle acquired MySQL, there is a potential risk of closing the source of MySQL, so the community uses a branch to avoid this risk. MariaDB's purpose is to be fully compatible with MySQL, including API and command line, so that it can easily become a substitute for MySQL. The CentOS 7 version removed the MySQL database software from the default program list and replaced it with mariadb.
centos 7 correct command to uninstall mariadb
#List all installed rpm packages
rpm -qa | grep mariadb
#Uninstall
rpm -e mariadb-libs-5.5.37-1.el7_0.x86_64
Error: Dependency test failed:
libmysqlclient.so.18 () (64bit) is required by (installed) postfix-2: 2.10.1-6.el7.x86_64
libmysqlclient.so.18 (libmysqlclient_18) (64bit) is required
#Force uninstall, because there is no --nodeps
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64
mysql: https://dev.mysql.com/downloads/mysql/
Unzip after downloading: tar -xf mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar
Unzipped things:
mysql related packages
libaio-0.3.109-13.el7.x86_64.rpm: http://mirror.centos.org/centos/6/os/x86_64/Packages/libaio-0.3.107-10.el6.x86_64.rpm
Install interdependent packages in order of installation:
rpm -ivh mysql-community-common-*. rpm
rpm -ivh mysql-community-libs-*. rpm
rpm -ivh mysql-community-client-*. rpm
rpm -ivh libaio-0.3.107-10.el6.x86_64.rpm
rpm -ivh mysql-community-server-*. rpm
The last step of the installation may prompt that the net-toos and perl dependencies are missing. Use yum install perl to install.
After the installation is complete, you must first set the mysql login password
First modify /etc/my.cnf to disable the password, log in through mysql -uroot and set a new password, and then restart again to log in normally with the new password.
vi /etc/my.cnf add skip-grant-tables in the last line to save and exit
Restart mysql: systemctl restart mysqld.service
At this point you can log in with mysql -uroot
Change the root password after login: use mysql;
update user set authentication_string = password ("root") where user = "root";
Finally, go to vi /etc/my.cnf and remove the added skip-grant-tables
At this time, mysql cannot be connected remotely
firewall-cmd --zone = public --add-port = 3306 / tcp --permanent
firewall-cmd --reload
systemctl stop firewalld.service #Stop
systemctl disable firewalld.service #Disable
Finally, allow remote connections
The remote can be achieved by modifying the table:
mysql -uroot -p
mysql> use mysql;
mysql> update user set host = ‘%‘ where user = ‘root’;
mysql> select host, user from user;
At this time, mysql can be connected remotely, but any operation after connection will prompt:
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
mysql5.7 first login to modify the root password
Use the following statement to change the password: alter user ‘root‘ @ ‘localhost’ identified by ‘xxx’ PASSWORD EXPIRE NEVER account unlock;
There is a password expired, you do not specify, that is, the default value is 360 days specified by default_password_lifetime, need to pay attention.
If the set password is too simple, it will prompt: ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
That is, the password does not comply with the rules. The password must be set as complex as possible, with numbers, capital letters, special symbols, etc.
centos7 install mysql-5.7.21 offline