Use yum to install mysql and centosyum in CentOS 7.0
The default database of CentOS7 is mariadb, which is not used to the configuration. Therefore, it is decided to change it to mysql. However, the yum source of CentOS7 does not seem to have mysql by default. To solve this problem, we need to download the mysql repo source first.
1. Download the mysql repo Source
$ wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
2. Install the mysql-community-release-el7-5.noarch.rpm package
$ sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm
After installing this package, you will get the yum repo source for both mysql:/etc/yum. repos. d/mysql-community.repo,/etc/yum. repos. d/mysql-community-source.repo.
3. Install mysql
$ sudo yum install mysql-server
You can install it as prompted, but there is no password after installation, and you need to reset the password
4. Reset the mysql password
$ mysql -u root
The following ERROR may be reported during logon: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql. sock '(2), because of/var/lib/mysql access permission issues. The following command changes the owner of/var/lib/mysql to the current user:
$ sudo chown -R root:root /var/lib/mysql
Restart mysql Service
$ service mysqld restart
Next, log on to reset the password:
$ Mysql-u root // directly press enter to enter the mysql console mysql> use mysql; mysql> update user set password = password ('000000') where user = 'root '; mysql> exit;