安装
[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