服务器环境是centos 7.6 这篇教程是通过yum方式安装的。
安装依赖
yum install libaio wget -y
检查MYSQL是否已安装(二次安装需要考虑)
yum list installed | grep mysql
卸载方法
yum -y remove mysql-libs.x86_64
下载MySQL官网的仓库文件
cd /tmp
wget http://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
yum localinstall mysql80-community-release-el7-1.noarch.rpm
验证是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
安装mysql
yum install mysql-community-server -y
此时MySQL 安装完成,它包含了
mysql-community-server、mysql-community-client
mysql-community-common、mysql-community-libs 四个包
执行
rpm -qi mysql-community-server.x86_64 0:8.0.16-2.el7
然后
whereis mysql
可以看到MySQL 的安装目录是 /usr/bin/
启动服务
systemctl start mysqld
systemctl enable mysqld
systemctl status mysqld
安装后查找初始化的密码:
cat /var/log/mysqld.log | grep password
进入mysql
mysql -uroot -p
修改初始化密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
设置允许远程连接
mysql> use mysql;
mysql> select host,user,authentication_string,plugin from user;
mysql> update user set host='%' where user='root';
mysql> flush privileges;
查看字符集
mysql> status
根据修改后的密码登录下成功就好