当前位置:首页 - MySql

linux centos7安装mysql教程

作者:高景洋 日期:2022-12-13 14:13:29 浏览次数:656

如何在linux centos 7 下安装mysql,请看以下步骤~



1、下载MySQL rpm包 wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

2、解压rpm包 rpm -ivh mysql57-community-release-el7-9.noarch.rpm

3、在centos输入指令# yum -y install mysql-community-server
************************
执行后,如果有以下报错,则执行:yum -y install mysql-community-server --nogpgcheck,用来禁掉GPG验证检查
************************
warning: /var/cache/yum/x86_64/7/mysql57-community/packages/mysql-community-client-5.7.38-1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
The GPG keys listed for the "MySQL 5.7 Community Server" repository are already installed but they are not correct for this package.
Check that the correct key URLs are configured for this repository.
Failing package is: mysql-community-client-5.7.38-1.el7.x86_64
GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

4、启动mysql:systemctl start mysqld.service

5、查看mysql状态:systemctl status mysqld.service

6、查看mysql初始密码:grep "password" /var/log/mysqld.log

7、首次登录mysql: mysql -uroot -p

8、修改root默认密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';

9、如果提示:
Your password does not satisfy the current policy requirements
这是因为密码强度不符合设置导致

10、查看当前密码安全设置:
SHOW VARIABLES LIKE 'validate_password%';
修改密码复杂度设置:
set global validate_password_policy=LOW;

11、开启mysql远程访问:
grant all privileges on *.* to 'root'@'192.168.0.1' identified by 'password' with grant option;
注:password--是你设置你的mysql远程登录密码。

12、执行 flush privileges;


ps:设置mysql 忽略表名大小写:
a、vi /etc/my.cnf
b、在文件最后添加 lower_case_table_names=1
mysql 日志文件位置 ,在/etc/my.cnf 中设置 ,默认位置在 log-error=/var/log/mysqld.log。
出现异常时,可以通过该文件内容 查看异常。
c、查看Mysql版本 select version();


本文永久性链接:
<a href="http://r4.com.cn/art217.aspx">linux centos7安装mysql教程</a>
当前header:Host: r4.com.cn X-Host1: r4.com.cn X-Host2: r4.com.cn X-Host3: 127.0.0.1:8080 X-Forwarded-For: 3.138.33.178 X-Real-Ip: 3.138.33.178 X-Domain: r4.com.cn X-Request: GET /art217.aspx HTTP/1.1 X-Request-Uri: /art217.aspx Connection: close Accept: */* User-Agent: Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com) Referer: http://www.yuezhiji.net/art217.aspx