The steps for installing mysql-communit-5.7 on centos7.4 as following:
At first, remove the mariadb on your centos. You can check how many mariadb packages on OS with command below:
rpm -qa|grep mariadb
mariadb-libs-5.5.56-2.el7.x86_64
mariadb-5.5.56-2.el7.x86_64
mariadb-server-5.5.56-2.el7.x86_64
Then use rpm -e command to remove them.
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
rpm -e mariadb-5.5.56-2.el7.x86_64 --nodeps
rpm -e mariadb-server-5.5.56-2.el7.x86_64 --nodeps
Next, we will install mysql packages. After we download installation package from offical website, we got a file named mysql-5.7.22-1.el7.x86_64.rpm-bundle.tar. We could extract it to anywhere. But please remember that we should use root account to install mysql rather than common user. OK, we can find there are a lot of rpm files. And we only install four rpm packages. Follow steps below:
rpm -ivh mysql-community-common-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.22-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.22-1.el7.x86_64.rpm
At last, let's start the mysql service.
[root@localhost kevin]# systemctl start mysqld.service
[root@localhost kevin]# systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2018-06-09 04:29:46 EDT; 24s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 3695 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid $MYSQLD_OPTS (code=exited, status=0/SUCCESS)
Process: 3602 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 3697 (mysqld)
CGroup: /system.slice/mysqld.service
└─3697 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
Jun 09 04:29:00 localhost.localdomain systemd[1]: Starting MySQL Server...
Jun 09 04:29:46 localhost.localdomain systemd[1]: Started MySQL Server.
And then verify if it's running.....
[root@localhost kevin]# netstat -an | grep 3306
tcp6 0 0 :::3306 :::* LISTEN
Oh, one more thing, dont forget to retrive the initial password.
# cat /var/log/mysqld.log
2018-06-09T08:29:37.324687Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2018-06-09T08:29:38.006584Z 0 [Warning] InnoDB: New log files created, LSN=45790
2018-06-09T08:29:38.124151Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2018-06-09T08:29:38.216176Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 3f71ffb2-6bbf-11e8-9b7f-000c29829cee.
2018-06-09T08:29:38.220202Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2018-06-09T08:29:38.222647Z 1 [Note] A temporary password is generated for root@localhost:
PhR4by=l_Uoi
Oh, it has not been closed. I can't connect to server with root user. So continue to search solution from the reference blog. I checked the user table. The host is "localhost" for root user. Obviously, I can't connect to mysql from remote server.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select host, user from user;
+-----------+---------------+
| host | user |
+-----------+---------------+
| localhost | mysql.session |
| localhost | mysql.sys |
| localhost | root |
+-----------+---------------+
3 rows in set (0.00 sec)
mysql> update user set host = "%" where user = 'root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
But I still can't connect to the server. All right, finally, at the end of blog, I find solution, flush the cach.
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
Bing go!!!
Reference: