1.安装yum
yum install lrzsz -y
2.安装wget 用于下载mysql源安装包
yum install wget
3.下载mysql源安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
4.安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
5.检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
6.修改 vim /etc/yum.repos.d/mysql-community.repo源 改变默认安装的mysql版本。
比如要安装5.6版本,将5.7源的enabled=1改成enabled=0。然后再将5.6源的enabled=0改成enabled=1即可。
7.安装MySQL
yum install mysql-community-server
8.启动MySQL服务
systemctl start mysqld
停止MySQL服务
systemctl stop mysqld
9.开机启动msql服务
systemctl enable mysqld
systemctl daemon-reload
10.进入mysql
mysql -u root
show databases;查看数据库
退出MySQL
exit
11.设置密码
创建服务器
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
进入mysql数据库
use mysql;
查看user表
select host,user,password from user;
删除除%外其他用户
delete from user where host !='%';
退出MySQL 重启服务
exit
systemctl start mysqld
systemctl stop mysqld
重新进入mysql
mysql -u root -p
密码
root
12.处理mysql中文乱码
查看mysql编码格式
show variables like 'character%';
编辑配置文件
vim /etc/my.cnf
在第一行[mysqld]下插入
character-set-server=utf8
在最后插入
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
13.导入mysql数据库文件
source 路径
转载于:https://www.cnblogs.com/wangmeng960111/p/10990057.html