热门IT资讯网

centos7安装mysql和mysqlclient遇到的坑怎么解决

发表于:2024-11-24 作者:热门IT资讯网编辑
编辑最后更新 2024年11月24日,这篇文章主要介绍了centos7安装mysql和mysqlclient遇到的坑怎么解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇centos7安装mysql和mysq

这篇文章主要介绍了centos7安装mysql和mysqlclient遇到的坑怎么解决的相关知识,内容详细易懂,操作简单快捷,具有一定借鉴价值,相信大家阅读完这篇centos7安装mysql和mysqlclient遇到的坑怎么解决文章都会有所收获,下面我们一起来看看吧。

1. 添加mysql yum源

mysql官网>downloads>mysql yum repository找到合适版本的yum源

$wget https://dev.mysql.com/get/mysql80-community-release-el7-2.noarch.rpm$sudo rpm -uvh mysql80-community-release-el7-2.noarch.rpm #查看mysql数据库各个版本信息$yum repolist all | grep mysql

2. 选择安装版本

修改/etc/yum.repos.d/mysql-community.repo 文件,选择mysql5.7版本

# enable to use mysql 5.6[mysql56-community]name=mysql 5.6 community serverbaseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/enabled=0 # 禁止gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-mysql # enable to use mysql 5.7[mysql57-community]name=mysql 5.7 community serverbaseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/enabled=1 # 安装gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-mysql [mysql80-community]name=mysql 8.0 community serverbaseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/enabled=0 # 禁止gpgcheck=1gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-mysql

3. 安装

#执行以下命令安装mysqlyum install mysql-community-server#启动mysql(centos7中)systemctl start mysqld.service#低版本的操作系统可用以下指令service mysqld start#查看mysql状态systemctl status mysqld.service#低版本操作系统可用以下指令service mysqld status

4. 查看并修改密码

$grep "password" /var/log/mysqld.log2019-04-11t08:17:16.706096z 1 [note] a temporary password is generated for root@localhost: ux#bkam(k1q-$mysql -u root -p>ux#bkam(k1q- # 修改密码mysql>alter user 'root'@'localhost' identified by 'complex password';mysql>set global validate_password_policy=0;mysql>set global validate_password_length=1;mysql>alter user 'root'@'localhost' identified by 'simple password';

5. 配置开放3306端口

授权的方式允许任何主机访问mysql服务器:【一般采用这个即可,限制端口访问交由firewalld来做】

mysql>grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;

限定ip访问:

mysql>grant all privileges on *.* to 'jack'@'10.10.50.127' identified by 'password' with grant option;

关于"centos7安装mysql和mysqlclient遇到的坑怎么解决"这篇文章的内容就介绍到这里,感谢各位的阅读!相信大家对"centos7安装mysql和mysqlclient遇到的坑怎么解决"知识都有一定的了解,大家如果还想学习更多知识,欢迎关注行业资讯频道。

0