Home > Database > Mysql Tutorial > body text

How to solve the pitfalls encountered when installing mysql and mysqlclient on centos7

PHPz
Release: 2023-05-28 11:10:06
forward
1515 people have browsed it

1. Add mysql yum source

mysql official website>downloads>mysql yum repository to find the appropriate version of yum source

$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
Copy after login

2 . Select the installation version

Modify the /etc/yum.repos.d/mysql-community.repo file and select the mysql5.7 version

# 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
Copy after login

3. Install

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

4. View and change the password

$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';
Copy after login

5. Configure open 3306 port

Authorization method allows any host to access the mysql server: [Generally use this, restrict port access and leave it to firewalld]

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

Limit ip access:

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

The above is the detailed content of How to solve the pitfalls encountered when installing mysql and mysqlclient on centos7. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!