检查系统版别
[root@vhpuccrv4yxgkqwq-0530595 ~]# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)
本文一切的过程和流程都是根据这个版别进行阐明,其他版别仅供参考。一起阐明一点,本文装置过程仅仅是测试学习使用,实在生产环境请让专业的运维同学去做 !
使用 yum 装置
装置 mysql-community-common
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-common-8.0.22-1.el7.x86_64.rpm
yum -y install mysql-community-common-8.0.22-1.el7.x86_64.rpm
装置 mysql-community-client
- 先装置 mysql-community-client-plugins
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
yum -y install mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm
- 装置 mysql-community-libs
该过程中要先卸载 mariadb ,因为它是 centos7 默许的数据库,会和 mysql 抵触
rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.60-1.el7_5.x86_64
再履行 mysql-community-libs 装置命令
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-libs-8.0.22-1.el7.x86_64.rpm
yum -y install mysql-community-libs-8.0.22-1.el7.x86_64.rpm
- 装置 mysql-community-client
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-client-8.0.22-1.el7.x86_64.rpm
yum -y install mysql-community-client-8.0.22-1.el7.x86_64.rpm
- 装置 mysql-community-server
wget http://mirrors.163.com/mysql/Downloads/MySQL-8.0/mysql-community-server-8.0.22-1.el7.x86_64.rpm
yum -y install mysql-community-server-8.0.22-1.el7.x86_64.rpm
MySQL 简略配置
初始化暗码
# 启动MySQL
systemctl restart mysqld
# 检查状况
systemctl status mysqld
#检查初始化暗码
grep password /var/log/mysqld.log
#修正初始化暗码,履行如下命令,装置完成后必须修正初始化暗码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your password'
flush privileges;
#修正初始化暗码的方法二
/usr/bin/mysqladmin -u root password 'root'
/usr/bin/mysqladmin -u root -p '123' password 'root'
配置字符集
vim /etc/my.cnf
# MySQL设置大小写不灵敏:默许:区别表名的大小写,不区别列名的大小写
# 0:大小写灵敏 1:大小写不灵敏
lower_case_table_names=1
# 默许字符集
character-set-server=utf8
卸载MySQL
检查装置的MySQL插件
rpm -qa | grep mysql
卸载命令
卸载 mysql yum库
#卸载MySQL
yum remove -y mysql-libs mysql-common
#删去MySQL下的数据文件
rm -rf /var/lib/mysql
#删去MySQL的配置文件
rm -rf /etc/my.cnf
#删去MySQL组件
yum -y remove mysql80-community-release-el7-3.noarch.rpm
rm -f /etc/yum.repos.d/mysql*
登录MySQL
本地登录:mysql -u root -p
远程登录:mysql -P 3306 -h ip -u root -p
客户端东西衔接
- 承认防火墙是否封闭
systemctl status firewalld #检查防火墙状况
systemctl stop firewalld
systemctl disable firewalld.service #设置开机不启动
- 客户端无法直连怎么办?
敞开mysql root用户允许一切IP衔接
use mysql;
select User, Host FROM user;
update user set host='%' where user='root' and host='localhost';
#办法二
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'root' WITH GRANT OPTION;
FLUSH PRIVILEGES; #改写权限
- Sequel pro 客户端衔接问题
MySQL said: Authentication plugin 'caching_sha2_password' cannot be loaded: dlopen(/usr/local/mysql/lib/plugin/caching_sha2_password.so, 2): image not found
处理方法:
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'your password';