centos8通过yum安装mysql8

安装Yum Repository

[root@localhost ~]# wget https://repo.mysql.com//mysql80-community-release-el8-1.noarch.rpm

使用rpm来安装MySQL

[root@localhost ~]# rpm -ivh mysql80-community-release-el8-1.noarch.rpm

使用yum安装mysql服务

[root@localhost ~]# yum install mysql-server

检查是否已经设置为开机启动MySQL服务

[root@localhost ~]# systemctl list-unit-files|grep mysqld
mysqld.service disabled
mysqld@.service disabled

设置开机启动

[root@localhost ~]# systemctl enable mysqld.service
[root@localhost ~]# systemctl list-unit-files|grep mysqld
mysqld.service enabled
mysqld@.service disabled

启动服务

[root@localhost ~]# systemctl start mysqld.service

尝试mysql登录

[root@localhost ~]# mysql -hlocalhost -uroot -p

创建用户:

#创建用户
mysql> create user 'tyjs09'@'%' identified by 'tyjs09'; Query OK, 0 rows affected (0.01 sec) #授权用户可以访问nacos_config数据库 mysql> grant all privileges on nacos_config.* to 'tyjs09'@'%'; Query OK, 0 rows affected (0.00 sec) #权限率先你 mysql> flush privileges; Query OK, 0 rows affected (0.01 sec) mysql>

 修改密码:

mysql> mysql> altertyjs09'@'%' identified with mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> 

 给root用户创建远程连接:

#创建用于远程连接的root用户
mysql> create user 'root'@'%' identified by 'root';
Query OK, 0 rows affected (0.01 sec)

#给root用户授权
mysql> grant all privileges on *.* to 'root'@'%' with grant option;
Query OK, 0 rows affected (0.01 sec)
#刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#给用户设置密码
mysql> alter user 'root'@'%' identified with mysql_native_password by '123456';
Query OK, 0 rows affected (0.00 sec)
#刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

 给本地用户设置登录密码:

mysql> alter user 'root'@'localhost' identified with mysql_native_password BY '123456';
Query OK, 0 rows affected (0.01 sec)

 

posted @ 2022-01-11 19:00  linuxTang  阅读(494)  评论(0)    收藏  举报