包含以下三个部分:mysql安装,mysql密码重置、mysql配置远程访问。
一 centos安装mysql
1、wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
2、yum -y install mysql57-community-release-el7-10.noarch.rpm
3、yum -y install mysql-community-server
安装过程如果出现以下错误,可以调用
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Importing GPG key 0x5072E1F5: Userid : "MySQL Release Engineering " Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5 Package : mysql57-community-release-el7-10.noarch (@/mysql57-community-release-el7-10.noarch) From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql Public key for mysql-community-common-5.7.42-1.el7.x86_64.rpm is not installed Failing package is: mysql-community-common-5.7.42-1.el7.x86_64 GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022
然后调用yum -y install mysql-community-server重新安装。
4、systemctl start mysqld.service
调用成功后可以使用service mysqld status 查看mysql的状态
转存失败重新上传取消
二 密码重置
1、grep "password" /var/log/mysqld.log (备注:查看默认临时密码)
2、mysql -uroot -p (备注:输入刚刚默认的密码)
3、set global validate_password_policy=0;
4、set global validate_password_length=5;
5、ALTER USER 'root'@'localhost' IDENTIFIED BY '你的新密码' ;
6、 SHOW VARIABLES LIKE 'validate_password%';
三 配置远程访问
1、查看数据库
show databases;
切换到系统数据库mysql:use mysql;
查看user的认证信息:Select Host, User, authentication_string from user;
授权远程访问:
grant all privileges on *.* to root@'%'identified by '输入你自己的mysql密码';