前言
服务器换来换去的,一下子Ubuntu要安装MySQL数据库,一下子CentOS也要安装,记录一下传统安装方式,下次还是用docker安装吧。
一、安装下载MySQL
(1)下载MySQL的yum源配置
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
(2)安装MySQL的yum源
yum -y install mysql57-community-release-el7-11.noarch.rpm
(3)yum方式安装MySQL
yum -y install mysql-server --nogpgcheck
二、执行MySQL服务
(1)查看MySQL状态
systemctl status mysql.service
(2)启动MySQL服务
systemctl start mysqld.service
(3)关闭MySQL服务
systemctl stop mysqld.service
(4)重启MySQL服务
systemctl restart mysqld.service
(5)开启开机自启动MySQL服务
systemctl enable mysqld.service
三、配置MySQL远程访问
(1)获取临时密码
cat /var/log/mysqld.log| grep password
(2)修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456Aa@666';
(3)授权用户
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456Aa@666' WITH GRANT OPTION;
(4)更新授权
flush privileges;
(5)查看授权的记录列表
select User, Host from mysql.user;
四、相关问题
(1)No package wget available.
在通过yum安装wget的时候出现报错【No package wget available.】,一般是因为yum源的问题。
1.通过curl下载yum源
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
2.生成缓存
yum makecache
3.更新yum源
yum -y update
4.再次下载wget
yum install -y wget