Install MySQL database in centOS7 and centos7mysql Database
1. Check whether the system comes with the original mysql installation package. If yes, uninstall and delete the package first. Otherwise, the installation and startup will fail;
# Rpm-qa | grep mysql check which installation packages are available. If you skip them directly, it indicates that there is no installation package, and you can directly go to 2nd and 3.
# Yum remove mysql-server mysql-libs compat-mysql51 pay attention to this Code, uninstall is not clean
# Rm-rf/var/lib/mysql
# Rm/etc/my. cnf
# Rpm-qa | grep mysql: Check whether the data has been deleted. If the data has not been deleted, delete the data.
For example:
Two installation packages are available.
MySQL-server-5.6.19-1.linux_glibc2.5.x86_64.rpm
MySQL-client-5.6.19-1.linux_glibc2.5.x86_64.rpm
Delete these two services (remove the suffix)
# rpm –e MySQL-client-5.6.19-1.linux_glibc2.5.x86_64# rpm -e MySQL-server-5.6.19-1.linux_glibc2.5.x86_64
View the residual directory:
# whereis mysql
Then delete the mysql directory:
# rm –rf /usr/lib64/mysql
2. Download the mysql repo Source
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
3. Install the mysql-community-release-el7-5.noarch.rpm package
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
4. Install mysql
#yum install mysql-community-server
5. Restart the MySQL service after the installation is successful.
#service mysqld restart
6. Reset the password
# Mysql-urootmysql> use mysql; mysql> update user set password = password ('000000') where user = 'root'; mysql> flush privileges; this is a success. Mysql> exit;
Do you want to know if the password is correct? It can be verified; that is, exit and re-log on to the root account;
# mysql -uroot -p
-P must be added here, and he will remind you to Enter password:
You only need to enter the password you just set to enter. If you cannot enter it, execute 6) and set it again. I set the password to 123456, after that, you must log on to MySQL as the root user: # mysql-uroot-p