300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 数据库的安装 授权以及远程连接

数据库的安装 授权以及远程连接

时间:2023-05-31 19:48:54

相关推荐

数据库的安装 授权以及远程连接

目录

安装数据库

授权

安装navicat,连接数据库

安装workbench,连接数据库

测试

安装数据库

找到我们需要的mysql的包[在此查找]

所需的包:

mysql-community-client[client快捷]

mysql-community-common[common快捷]

mysql-community-devel[devel快捷]

mysql-community-libs[libs快捷]

mysql-community-server[server快捷]

使用wget下载

[root@zhenzhu ~]# cd /usr/src[root@zhenzhu src]# lsdebug kernels[root@zhenzhu src]# wget /yum/mysql-5.7-community/el/7/x86_64/mysql-community-client-5.7.40-1.el7.x86_64.rpm /yum/mysql-5.7-community/el/7/x86_64/mysql-community-common-5.7.40-1.el7.x86_64.rpm /yum/mysql-5.7-community/el/7/x86_64/mysql-community-devel-5.7.40-1.el7.x86_64.rpm /yum/mysql-5.7-community/el/7/x86_64/mysql-community-libs-5.7.40-1.el7.x86_64.rpm /yum/mysql-5.7-community/el/7/x86_64/mysql-community-server-5.7.40-1.el7.x86_64.rpm 安装过程略[root@zhenzhu src]# lsdebugkernelsmysql-community-client-5.7.40-1.el7.x86_64.rpmmysql-community-common-5.7.40-1.el7.x86_64.rpmmysql-community-devel-5.7.40-1.el7.x86_64.rpmmysql-community-libs-5.7.40-1.el7.x86_64.rpmmysql-community-server-5.7.40-1.el7.x86_64.rpm[root@zhenzhu src]#

安装

[root@zhenzhu src]# yum -y localinstall *.rpm安装过程略[root@zhenzhu src]# systemctl status mysqld● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled;>Active: inactive (dead)Docs: man:mysqld(8)/doc/refman/en/using-systemd.html[root@zhenzhu src]#

启动

[root@zhenzhu src]# systemctl disable --now firewalld //关闭防火墙Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@zhenzhu src]# vim /etc/selinux/config//关闭selinux[root@zhenzhu src]# setenforce 0 //设置临时生效[root@zhenzhu src]# systemctl start mysqld //mysql服务开启临时生效[root@zhenzhu src]# systemctl enable mysqld //mysql服务开机自启[root@zhenzhu src]# systemctl status mysqld● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled;>Active: active (running) since Tue -12-27 17:54:05 CST; 2min>Docs: man:mysqld(8)/doc/refman/en/using-systemd.htmlMain PID: 13021 (mysqld)Tasks: 27 (limit: 12241)Memory: 293.1MCGroup: /system.slice/mysqld.service└─13021 /usr/sbin/mysqld --daemonize --pid-file=/var/run>Dec 27 17:54:02 systemd[1]: Starting MySQL Serv>Dec 27 17:54:05 systemd[1]: Started MySQL Serve>[root@zhenzhu src]# ss -antl //mysql服务端口号为3306State Recv-Q Send-Q Local Address:Port Peer Address:Port Process LISTEN 01280.0.0.0:220.0.0.0:* LISTEN 0128 [::]:22 [::]:* LISTEN 080 *:3306 *:* [root@zhenzhu src]#

登陆需要密码,但是没有设置密码,需要查看临时密码使用(单次使用,使用完失效)

[root@zhenzhu src]# grep password /var/log/mysqld.log -12-27T09:54:03.476981Z 1 [Note] A temporary password is generated for root@localhost: daV</9;.k-se //密码为daV</9;.k-se[root@zhenzhu src]#

链接mysql

[root@zhenzhu src]# mysql -uroot -p'daV</9;.k-se' //密码有特殊字符用单引号引起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 2Server version: 5.7.40Copyright (c) 2000, , Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

设置mysql的root用户密码(此root身份非主机root用户身份,这里指mysql的root)

mysql> set password = password("ZhenZhu123!"); //需符合密码策略,命令需要以;结尾Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>

重新登陆测试

mysql> quitBye[root@zhenzhu src]# mysql -uroot -p'ZhenZhu123!'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 3Server version: 5.7.40 MySQL Community Server (GPL)Copyright (c) 2000, , Oracle and/or its affiliates.Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>

服务初始化

[root@zhenzhu ~]# mysql_secure_installationSecuring 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 configurationof 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 havea user account created for them. This is intended only fortesting, and to make the installation go a bit smoother.You should remove them before moving into a productionenvironment.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 atthe root password from the network.Disallow root login remotely? (Press y|Y for Yes, any other key for No) : n //是否拒绝root远程连接... skipping.By default, MySQL comes with a database named 'test' thatanyone can access. This is also intended only for testing,and should be removed before moving into a productionenvironment.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 changesmade 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@zhenzhu ~]#

授权

授权root用户在本机(登陆点ip)上登录访问所有数据库

mysql> grant all on *.* to 'root'@'192.168.204.1' identified by 'ZhennZhu123!';Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>

安装navicat,连接数据库

连接配置

连接成功

安装workbench,连接数据库

连接配置

连接成功

测试

创建数据库zhenzhu

mysql> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys|+--------------------+4 rows in set (0.00 sec)mysql> CREATE DATABASE zhenzhu;Query OK, 1 row affected (0.00 sec)mysql> SHOW DATABASES;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys|| zhenzhu |+--------------------+5 rows in set (0.00 sec)mysql>

navicat和workbench可读取

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。