1、检查系统默认自带的mariadb
rpm -qa | grep mariadb
[root@tainshu ~]#
[root@tainshu ~]# rpm -qa | grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
[root@tainshu ~]#
2、卸载系统默认自带的mariadb,避免与即将安装的mysql产生冲突
rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
[root@tainshu ~]#
[root@tainshu ~]# rpm -e --nodeps mariadb-libs-5.5.64-1.el7.x86_64
[root@tainshu ~]# rpm -qa | grep mariadb
[root@tainshu ~]# ^C
[root@tainshu ~]#
3、新建mysql的按照目录 /usr/local/mysql/mysql-5.7
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# pwd
/usr/local/mysql/mysql-5.7
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]#
4、 sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
[root@tainshu mysql-5.7]# sudo rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Retrieving http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Preparing... ################################# [100%]
Updating / installing...
1:mysql-community-release-el7-5 ################################# [100%]
[root@tainshu mysql-5.7]#
5、安装 yum install mysql-server -y
Installed:
mysql-community-server.x86_64 0:5.6.48-2.el7
Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 mysql-community-client.x86_64 0:5.6.48-2.el7 mysql-community-common.x86_64 0:5.6.48-2.el7
mysql-community-libs.x86_64 0:5.6.48-2.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7
perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7
Complete!
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]#
6、启动 systemctl start mysqld.service / service mysqld restart
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# systemctl start mysqld.service
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# systemctl status mysqld.service
● mysqld.service - MySQL Community Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2020-06-18 02:15:36 CST; 7min ago
Process: 24602 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
Process: 24539 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
Main PID: 24601 (mysqld_safe)
CGroup: /system.slice/mysqld.service
├─24601 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─24766 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --pid-file=/var/run/mysq...
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: /usr/bin/mysqladmin -u root -h tainshu password 'new-password'
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: Alternatively you can run:
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: /usr/bin/mysql_secure_installation
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: which will also give you the option of removing the test
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: databases and anonymous user created by default. This is
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: strongly recommended for production servers.
Jun 18 02:15:35 tainshu mysql-systemd-start[24539]: See the manual for more instructions.
Jun 18 02:15:35 tainshu mysqld_safe[24601]: 200618 02:15:35 mysqld_safe Logging to '/var/log/mysqld.log'.
Jun 18 02:15:35 tainshu mysqld_safe[24601]: 200618 02:15:35 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jun 18 02:15:36 tainshu systemd[1]: Started MySQL Community Server.
[root@tainshu mysql-5.7]#
7、验证 mysql
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.48 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show tables ;
ERROR 1046 (3D000): No database selected
mysql> show databases ;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)
mysql>
mysql>
mysql>
8、变更密码:
mysql>
mysql>
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>
mysql> update user set password=passworD("123456") where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4 Changed: 4 Warnings: 0
mysql>
mysql>
mysql>
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
9、重启+登录
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]#
[root@tainshu mysql-5.7]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6.48 MySQL Community Server (GPL)
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
mysql>
mysql>
自己装了5.6&
算了无所谓