扫二维码与项目经理沟通
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流
服务器
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 Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=0 # 禁止 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql # Enable to use MySQL 5.7 [mysql57-community] name=MySQL 5.7 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/ enabled=1 # 安装 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql [mysql80-community] name=MySQL 8.0 Community Server baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/$basearch/ enabled=0 # 禁止 gpgcheck=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
3. 安装
#执行以下命令安装MySQL yum 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.log 2019-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遇到的一些坑和需要注意的知识点总结,感谢大家的阅读和对创新互联的支持。
我们在微信上24小时期待你的声音
解答本文疑问/技术咨询/运营咨询/技术建议/互联网交流