Install MySQL database in centOS7 and centos7mysql Database

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.