MySQL(一)-centos8安装MySQL8.x

MySQL(一)-centos8安装MySQL8.x_第1张图片
参考资料:
MySQL官方文档
高性能MySQL(第3版)

  • 系统以及工具相关

CentOS 8;
mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64;
IDEA 2020.1(数据库连接工具);

由于高性能MySQL这本书出版时间是2013年,那时的MySQL版本还处于5.X;
因此,涉及8.X的新功能都将是我通过"腾讯翻译+谷歌翻译+google+百度" 摸索 (猜)出来的;

  • 安装:
#搜索yum库中的mysql
[root@localhost /]# yum search mysql
Last metadata expiration check: 0:51:19 ago on Tuesday, July 07, 2020 AM06:37:22 PDT.
======================================================================================= Name & Summary Matched: mysql ========================================================================================
...
mysql-server.x86_64 : The MySQL server and related files
...
=========================================================================================== 
#安装命令;
[root@localhost /]# yum install mysql-server.x86_64

  • 设置开机启动:
#检查开机启动
[root@localhost /]# systemctl list-unit-files|grep mysqld
mysqld.service                                                         disabled
[email protected]                                                        disabled
#设置允许开机启动,且可以看到创建了一个link文件到mysqld.service,后续启动可以不用再找到mysqld.service所在的文件夹去启动了;
[root@localhost /]# systemctl enable mysqld.service
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
#再次检查可以看到mysqld.service已经是enable;
[root@localhost /]# systemctl list-unit-files|grep mysqld
mysqld.service                                                         enabled
[email protected]                                                        disabled
#查看mysql是否已经启动;
[root@localhost /]# ps -ef|grep mysql
root      30875   2574  0 07:33 pts/0    00:00:00 grep --color=auto mysql
#启动mysql;
[root@localhost /]# systemctl start mysqld.service
#进入mysql,注意由yum安装的mysql,root账户没有密码;需要进入后自己设置;
[root@localhost /]# mysql -u root
#设置root的密码;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
Query OK, 0 rows affected (0.02 sec)
mysql> EXIT
#验证,不输入密码登录失败;
[root@localhost /]# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost /]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 8.0.17 Source distribution

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#修改root账号的主机地址为%,以便远程连接;
mysql> USE mysql
mysql> update user set host ='%' where User ='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)


参考文章:
centOS8安装MySQL8
远程无法访问MySQL8

你可能感兴趣的:(mysql相关,centos,mysql)