mysqlkankan(good)MySQL数据库

搭建MySQL服务器

2023-01-18  本文已影响0人  技术老男孩

一、环境准备:

Ip地址 主机名 说明
192.168.88.50 Host50 配置yum源、关闭防火墙、关闭selinux1G内存 1颗CPU 20G硬盘
192.168.88.51 Host51 配置yum源、关闭防火墙、关闭selinux1G内存 1颗CPU 20G硬盘
注意事项:

二、搭建MySql步骤

第一步:解压mysql的tar包

[root@host50 ~]# tar -xf mysql-5.7.17.tar
[root@host50 ~]# ls mysql-community-*.rpm
mysql-community-client-5.7.17-1.el7.x86_64.rpm
mysql-community-common-5.7.17-1.el7.x86_64.rpm
mysql-community-devel-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.17-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.17-1.el7.x86_64.rpm
mysql-community-libs-5.7.17-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.17-1.el7.x86_64.rpm
mysql-community-minimal-debuginfo-5.7.17-1.el7.x86_64.rpm
mysql-community-server-5.7.17-1.el7.x86_64.rpm
mysql-community-test-5.7.17-1.el7.x86_64.rpm

第二步:安装

[root@host50 ~]# yum -y install mysql-community-*.rpm

第三步:启动服务

[root@host50 ~]# systemctl enable --now mysqld
[root@host50 ~]# netstat  -utnlp  | grep  3306  
tcp6       0      0 :::3306                 :::*                    LISTEN      15167/mysqld 
[root@host50 ~]# ps aux | grep mysqld
[root@host50 ~]# ps -C mysqld
mysql     15167  0.0 17.4 1119536 173856 ?      Sl   19:20   0:04 /usr/sbin/mysqld --daemonize --pid-file=/var/run/mysqld/mysqld.pid
root      16111  0.0  0.0 112824   976 pts/1    R+   22:35   0:00 grep --color=auto mysqld

第四步:配置初始密码

[root@host50 ~]# grep -i password  /var/log/mysqld.log
..... password is generated for root@localhost: p.7jr.uy.aiZ
[root@host50 ~]# mysql -uroot -p'p.7jr.uy.aiZ'
mysql: [Warning] ....
....
Type 'help;' or '\h' for help. ...
mysql> 
# 修改密码
mysql> alter user  root@"localhost" identified by "123qqq...A";
# 断开连接
mysql> exit;
[root@host50 ~]# mysql  -uroot -p123qqq...A
mysql: [Warning] ....
....
Type 'help;' or '\h' for help. ...
mysql> 
# 查看已有的库 ,发现功能可以使用即可
mysql> show databases;  
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
上一篇下一篇

猜你喜欢

热点阅读