安装mysql

本文档详细介绍了在CentOS系统中安装MySQL8,设置远程连接,修改数据库权限,解决grant语法错误的过程。包括安装MySQL,刷新权限,重启服务,以及修复grant all privileges语句的错误用法,确保MySQL服务开机启动,并演示了如何安全地登录MySQL。
摘要由CSDN通过智能技术生成

安装

[root@node05 ~]# yum install mysql-server
Is this ok [y/N]: y
[root@node05 ~]# mysql
ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/lib/mysql/mysql.sock’ (2)
[root@node05 ~]#
[root@node05 ~]# service mysqld start
[root@node05 ~]# mysql
mysql> show database;

修改数据库的访问权限

mysql> use mysql
mysql> show tables;

mysql> desc user;

mysql> select host,user,authentication_string from user;

mysql> update user set host=’%’ where user=‘root’;
mysql> alter user root identified with mysql_native_password by ‘123456’;

刷新权限

mysql> flush privileges;
mysql> quit

重启服务

service mysqld restart

mysql8设置远程连接报错grant all privileges on . to ‘root’@’%’ identified by

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘identified by ‘root’ with grant option’ at line 1
mysql8中已经不支持grant all privileges on . to ‘root’@’%’ identified by ‘密码’ with grant option这种写法。
应该使用
grant all privileges on . to ‘root’@’%’ ;

update user set host=’%’ where user=‘root’;
Grant all privileges on . to ‘root’@’%’;
alter user root identified with mysql_native_password by ‘123456’;

[root@node01 data]# cd /etc/yum.repos.d/
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-8.repo
yum clean all
yum makecache

设置mysql开机启动

chkconfig mysqld on
systemctl enable mysqld.service

进入mysql

[root@VM_0_3_centos ~]# mysql -u root -p

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值