首页 > 数据库 >mysql数据库安装

mysql数据库安装

时间:2022-12-27 22:33:45浏览次数:47  
标签:x86 5.7 安装 数据库 community 64 mysql root

mysql数据库安装

安装所需准备

#安装wget vim
[root@node ~]# yum -y install vim
Last metadata expiration check: 0:01:09 ago on Tue 27 Dec 2022 09:15:08 PM CST.
Dependencies resolved.
============================================================================================================
 Package                    Architecture       Version                          Repository             Size
============================================================================================================
Installing:
 vim-enhanced               x86_64             2:8.0.1763-16.el8                AppStream             1.4 M
 ...
 Complete!
[root@node ~]# which wget
/usr/bin/wget
#使用wget下载mysql安装所需要的包
client包的位置:(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm)
common包的位置:(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm)
devel包的位置:(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm)
libs包的位置:(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm)
server包的位置:(https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm)
#进入src使用wget下载
[root@node src]# cd /usr/src/
[root@node src]# wget https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm  https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm https://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm 
...
Downloaded: 5 files, 214M in 36s (5.87 MB/s)

进行本地安装

#安装本地的rpm包命令
[root@node src]# yum -y localinstall *.rpm
Last metadata expiration check: 0:09:11 ago on Tue 27 Dec 2022 09:15:08 PM CST.
Dependencies resolved.
============================================================================================================
 Package                    Arch       Version                                       Repository        Size
============================================================================================================
...
Complete!

关闭防火墙

[root@node src]# systemctl disable --now firewalld
[root@node src]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)
# 修改SELINUX=disabled
[root@node src]# vim /etc/selinux/config 
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
...

启动mysql

#状态显示为running
[root@node src]# systemctl start mysqld
[root@node src]# systemctl enable mysqld
[root@node src]# systemctl status mysqld
● mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Tue 2022-12-27 22:03:14 CST; 14s ago
     Docs: man:mysqld(8)
...
[root@node src]# ss -antl
State       Recv-Q      Send-Q           Local Address:Port             Peer Address:Port      Process      
LISTEN      0           128                    0.0.0.0:22                    0.0.0.0:*                      
LISTEN      0           128                       [::]:22                       [::]:*                      
LISTEN      0           80                           *:3306                        *:*                      

连接mysql

#查找临时登录密码
[root@node src]# grep password /var/log/mysqld.log 
2022-12-27T14:03:12.224710Z 1 [Note] A temporary password is generated for root@localhost: wlrw<NgZg3t-
#修改登录密码
[root@node src]# mysql -uroot -p'wlrw<NgZg3t-'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.40

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.
#修改密码
mysql> set password = password("RunTime123!");
Query OK, 0 rows affected, 1 warning (0.00 sec)


连接测试

[root@node ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.40 MySQL Community Server (GPL)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

mysql> 

服务初始化

[root@node ~]#  mysql_secure_installation 

Securing the MySQL server deployment.

Enter password for user root: 
The 'validate_password' plugin is installed on the server.
The subsequent steps will run with the existing configuration
of the plugin.
Using existing password for root.

Estimated strength of the password: 100 
#是否修改密码
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n 

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
#是否删除匿名用户
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
#是否不拒绝root远程登录
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

#删除测试数据库和访问权限
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
#是否重新加载权限表
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.

All done! 
[root@node ~]# 

标签:x86,5.7,安装,数据库,community,64,mysql,root
From: https://www.cnblogs.com/lqy0917/p/17009152.html

相关文章