1.安装yumyum 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.安装MySQLyum install mysql-community-server
8.启动MySQL服务 systemctl start mysqld
停止MySQL服务
systemctl stop mysqld
9.开机启动msql服务systemctl enable mysqld
systemctl daemon-reload
10.进入mysqlmysql -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 路径