CentOS7 安装 MySql

Posted 细品人生 的园子

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了CentOS7 安装 MySql相关的知识,希望对你有一定的参考价值。

1-阿里云 CentOS 7.3 X64

2-安装NET CORE

教程地址:https://www.microsoft.com/net/core#linuxcentos

3-安装 libaio-0.3.109-13.el7.x86_64.rpm  (安装mysql 时出现 libaio.so.1(64bit) ....的问题)

下载:wget http://mirror.centos.org/centos/7.4.1708/os/x86_64/Packages/libaio-0.3.109-13.el7.x86_64.rpm

          wget http://mirror.centos.org/centos/7.5.1804/os/x86_64/Packages/libaio-0.3.109-13.el7.x86_64.rpm

安装:rpm -ivh libaio-0.3.109-13.el7.x86_64.rpm

4-开始安装mysql 

4.1 查看 centos 版本

cat /etc/redhat-release 

 4.2 卸载 mariadb (系统自带)

    查看安装包:rpm -qa | grep mariadb 

    强制卸载:rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

                     rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64

 

 查看是否安装了mysql : 

 1 :rpm -qa | grep -i mysql

 2 : find / -name mysql

删除文件:rm -r 递归删除命令( 

 rm -r /usr/lib64/mysql 

rm -r /etc/selinux/targeted/active/modules/100/mysql )

 

删除配置文件: rm -rf /etc/my.cnf 

然后重新检测一遍是否还有 mysql 文件

4.3 下载安装包

 下载地址:wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar

 

 4.4 解压安装包 :tar -xvf mysql-5.7.19-1.el7.x86_64.rpm-bundle.tar

 

  使用一下命令进行安装 :rpm -ivh 文件名称 (下面是安装顺序)

  rpm -ivh mysql-community-common-5.7.19-1.el7.x86_64.rpm

   rpm -ivh mysql-community-libs-5.7.19-1.el7.x86_64.rpm

rpm -ivh mysql-community-libs-compat-5.7.19-1.el7.x86_64.rpm

rpm -ivh mysql-community-client-5.7.19-1.el7.x86_64.rpm

rpm -ivh mysql-community-server-5.7.19-1.el7.x86_64.rpm

rpm -ivh mysql-community-devel-5.7.19-1.el7.x86_64.rpm

 

4.5 初始化设置:mysqld --initialize --user=mysql

   查看初始化密码:grep \'temporary password\' /var/log/mysqld.log

4.6 重启服务:systemctl restart mysqld.service

 

4.7 修改密码:SET PASSWORD=PASSWORD(\'123456\'); --修改成123456

 

5 配置远程链接

 5.1 添加 账号:

  ---添加本地账号

mysql> CREATE USER \'monty\'@\'localhost\' IDENTIFIED BY \'some_pass\';
mysql> GRANT ALL PRIVILEGES ON *.* TO \'monty\'@\'localhost\'
    ->     WITH GRANT OPTION;
--添加远程访问账号
mysql> CREATE USER \'monty\'@\'%\' IDENTIFIED BY \'some_pass\'; mysql> GRANT ALL PRIVILEGES ON *.* TO \'monty\'@\'%\' -> WITH GRANT OPTION;

----把本地账号修改成远程可访问账号

update user set host = \'%\' where user = \'monty\';

FLUSH PRIVILEGES;  --如果不加这句,修改是不会生效的。

 

 

 6-修改mysql字符集

参考这个:http://www.cnblogs.com/woshimrf/p/5880055.html

 

 

 

参考文章:http://www.cnblogs.com/lgq2008/p/7146127.html?utm_source=itdadao&utm_medium=referral

http://blog.csdn.net/flyingaga/article/details/72818269

http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html

http://www.cnblogs.com/starof/p/4680083.html

 https://stackoverflow.com/questions/1559955/host-xxx-xx-xxx-xxx-is-not-allowed-to-connect-to-this-mysql-server

http://blog.csdn.net/bingjianit/article/details/54384299

以上是关于CentOS7 安装 MySql的主要内容,如果未能解决你的问题,请参考以下文章

Mysql系列二:Centos7.4安装mysql5.7.28源码

centos7安装mariadb(mysql的替代品)

CentOS7上安装MySQL总结

MySql之centos7.2安装mysql5.7.13

Centos7中编译安装MySQL(mysql-5.7)

基于centos7搭建MySQL数据库