1.下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm;
2.添加源
yum localinstall mysql57-community-release-el7-8.noarch.rpm;
3.检查mysql源 是否添加成功
yum repolist enabled | grep "mysql.*-community.*";
4.安装mysql
yum install mysql-community-server;
默认会安装4个包: 1.mysql-community-server; 2.mysql-community-client; 3.mysql-community-common; 4.mysql-community-libs;
5.检查是否安装成功
mysql -V;
6.守护进程
systemctl start mysqld #启动mysql systemctl restart mysqld #重启mysql systemctl stop mysqld #停止mysql systemctl enable mysqld #开机启动 systemctl daemon-reload #重载守护进程
7.取消默认密码
// 编辑mysql配置文件 vim /etc/my.cnf; // 在 [mysqld] 小节下添加一行: skip-grant-tables=1; // 重启mysql systemctl restart mysqld;
8.修改密码
// 上一步操作取消了默认密码,现在可以直接登录。登录之后重新设置密码为root update user set authentication_string = password('root'), password_expired = 'N', password_last_changed = now() where user = 'root';
9.远程链接设置
// 通常会有在本地navicat连接远程数据库的需求。在mysql数据库中执行 update user set host = '%' where user = 'root'; #允许所有ip连接 FLUSH PRIVILEGES; #刷新