centos7.6安装mysql8

参考链接:

  1. Centos7.6安装MySQL
  2. mysql8 允许远程登陆
  3. 解决mysql8 提示 ERROR 1410 (42000): You are not allowed to create a user with GRANT

查看系统版本

# cat /etc/redhat-release
CentOS Linux release 7.6.1810 (Core)

安装MySQL8


# mariadb也是MySQL数据库的一个分支,所以先将mariadb解决掉,以防以后安装数据   库出现版本对撞等问题
rpm -qa | grep mariadb
yum remove mariadb-libs -y

#下载rpm文件
wget https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm

#安装rpm
rpm -ivh mysql80-community-release-el7-7.noarch.rpm

#安装mysql
yum install mysql-server -y

#启动mysql-server
service mysqld start

#查看是否启动成功
ps -ef |grep mysqld
netstat -anp | grep 3306

#添加开机启动
chkconfig mysqld on

修改端口号

#端口号修改为6666

#修改配置文件
vim /etc/my.cnf
在[mysqld]里 添加 "port=6666" 

#重启mysql-server
service mysqld restart

无密码登录

#修改配置文件
vim /etc/my.cnf
在[mysqld]里 添加 "skip-grant-tables"

#重启mysql-server
service mysqld restart

#登录
mysql -u root

设置密码为空字符串

#登录
mysql -u root

#执行sql命令
mysql > use mysql;
mysql > update user set authentication_string='' where user='root';
exit;

#注释"skip-grant-tables"
vim /etc/my.cnf
#skip-grant-tables

#重启mysql-server
service mysqld restart

设置密码

mysql -u root -p
Enter password: 直接换行

mysql > ALTER USER 'root'@'localhost' IDENTIFIED BY '你的密码';
mysql > exit;

设置root用户远程登录

# 登录
mysql -u root -p
Enter password: 你的密码

# 使用mysql 数据库
mysql > use mysql;

# 特定用户的host 修改
mysql > update user set host='%' where user='root';

# 允许root用户远程登录
Grant all privileges on root.* to 'root'@'%';

#设置密码
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '你的密码';

#刷新权限
flush privileges;
exit;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值