安装mysql
复制粘贴安装mysql rpm
yum install -y https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.22-1.el6.x86_64.rpm
- 登陆mysql网站点我。导航到Download MySQL Community Server。
- 使用
yum
下载安装。
例子:
yum install -y https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-libs-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-common-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-client-5.7.22-1.el6.x86_64.rpm https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-community-server-5.7.22-1.el6.x86_64.rpm
使用yum按顺序下载这几个包,如果安装错误可以在这里查找依赖重新下载
- 下载安装后使用命令
rpm -qa|grep mysql
查看
mysql-community-common-5.7.22-1.el6.x86_64
mysql-community-client-5.7.22-1.el6.x86_64
mysql-community-libs-5.7.22-1.el6.x86_64
mysql-community-server-5.7.22-1.el6.x86_64
-
mysql
初始化
[root@xxx log]# service mysqld start
Initializing MySQL database: [ OK ]
Starting mysqld: [ OK ]
- 输入命令
mysql --version
mysql Ver 14.14 Distrib 5.7.22, for Linux (x86_64) using EditLine wrapper
配置mysql
- 设置密码请看我的这篇文章
- 配置MySQL的配置文件my.cnf
vi /etc/my.cnf
把下面的粘贴过去。
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_general_ci
init_connect='SET NAMES utf8mb4'
max_connections = 1000
#数据库主动链接超时,半年时间
wait_timeout = 15811200
粘贴好后 退出 vim
重启mysql
service mysqld restart
删除mysql
- 停止
mysql
服务
service mysqld stop
- 列出名叫
mysql
的已安装的包。
[root@xxx ~]# rpm -qa|grep mysql
mysql-community-common-5.7.22-1.el6.x86_64
mysql-community-client-5.7.22-1.el6.x86_64
mysql-community-libs-5.7.22-1.el6.x86_64
mysql-community-server-5.7.22-1.el6.x86_64
- 使用
yum remove
命令删除它们
yum remove mysql-community-common-5.7.22-1.el6.x86_64 mysql-community-client-5.7.22-1.el6.x86_64 ... ... ... ...
- 找到
mysql
的残留文件夹
find / -name mysql
/usr/lib64/mysql
/usr/share/mysql
/usr/bin/mysql
/etc/logrotate.d/mysql
/var/lib/mysql
/var/lib/mysql/mysql
rm -rf /usr/bin/mysql /var/lib/mysql ... ... ...
- 找到日志文件删除掉
rm -f /var/log/mysqld.log
完毕