博客列表 >软件实施-安装mysql-在线和离线安装

软件实施-安装mysql-在线和离线安装

益伦的博客
益伦的博客原创
2020年07月25日 23:26:492215浏览

1、在线安装mysql客户端
yum install mysql

2、安装开发用到的库以及包含文件
yum install mysql-devel

3、安装数据库服务器
yum install mysql-server
提示错误

解决方法
a、先安装wget
yum install wget
b、然后手动下载
wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

c、然后安装该数据库的rpm包
rpm -ivh mysql-community-release-el7-5.noarch.rpm
d、开始安装mysql-server
yum install mysql-server
安装已完成


启动mysql
systemctl start mysqld
登录mysql
mysql -u root

mysql> show databases;
+——————————+
| Database |
+——————————+
| information_schema |
| mysql |
| performance_schema |
+——————————+
3 rows in set (0.00 sec)
修改密码
mysql> set password for ‘root’@’localhost’ =password(‘123456’);
Query OK, 0 rows affected (0.00 sec)
mysql> mysql -u root -p

新增mysql用户aa,关闭防火墙关闭selinux,%表示可远程,localhost表示本地连接,新建用户需用root账户登入mysql新建,然后用windows中cmd执行:mysql -h 192.168.57.6 -u aa -p 输入密码即可连接

  1. 创建
  2. mysql> CREATE USER 'aa'@'%' IDENTIFIED BY '1234';
  3. Query OK, 0 rows affected (0.00 sec)
  4. 生效
  5. mysql> flush privileges;
  6. Query OK, 0 rows affected (0.01 sec)
  7. mysql> exit
  8. Bye
  9. [root@localhost my.cnf.d]# service mysqld restart
  10. Redirecting to /bin/systemctl restart mysqld.service

yum安装时出现state:sleeping pid:2091….
解决方法
rm -f /var/run/yum.pid 2091
在安装,未报错

离线安装mysql5.7.30离线安装mysql5.7.30

很慢地址:https://dev.mysql.com/downloads/mysql/5.7.html
检查库文件是否存在,如有删除。
[root@localhost Desktop]$ rpm -qa | grep mysql
mysql-libs-5.1.52-1.el6_0.1.x86_64
有的话删除
[root@localhost ~]# rpm -e —nodeps mysql-libs-5.1.52.x86_64
检查mysql组和用户是否存在,如无创建。
[root@localhost ~]# cat /etc/group | grep mysql
mysql:x:490:
[root@localhost ~]# cat /etc/passwd | grep mysql
mysql:x:496:490::/home/mysql:/bin/bash
以上为默认存在的情况,如无,执行添加命令:

创建用户:以root用户登录到数据库进行用户创建

创建用户:以root用户登录到数据库进行用户创建
CREATE USER 'username'@'host' IDENTIFIED BY 'password';
例如
CREATE USER 'test_admin'@'localhost' IDENTIFIED BY 'admin@123_S';
CREATE USER ‘test_admin2’@’%’ IDENTIFIED BY ‘’;
note:

username——将要创建的用户名;

host——指定该用户在哪个主机上可以登录,”localhost”指该用户只能在本地登录,不能在另外一台机器上远程登录,如果想远程登录,将”localhost”改为”%”,表示在任何一台电脑上都可以登录;也可以指定某台机器可以远程登录;

password——该用户的登录密码,密码可以为空,若为空则该用户可以不需要密码登录服务器。

更新密码
set password for 'aa'@'%' =password('1234');


1、mysql官网下载大礼包mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar,解压到/opt

只装这几个
mysql-community-server-5.7.30-1.el7.x86_64.rpm
mysql-community-client-5.7.30-1.el7.x86_64.rpm
mysql-community-devel-5.7.30-1.el7.x86_64.rpm(可以不装这个,用到C开发才用到)
但是devel依赖于lib,lib又依赖于common
mysql-community-libs-5.7.30-1.el7.x86_64.rpm
mysql-community-common-5.7.30-1.el7.x86_64.rpm
2、先安装依赖common
rpm -ivh mysql-community-common-5.7.30-1.el7.x86_64.rpm
如果出现错误提示with file from package mariadb-libs-1:5.5.56-2.e17.×86_64说明和mariadb冲突,则先移除,无提示继续下一步
rpm -e —nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64
或者这条命令
yum remove -y mariadb-libs(这条命令不需要联网)
3、安装libs、devel、client
rpm -ivh mysql-community-libs-5.7.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-devel-5.7.30-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
4、安装服务器
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
依赖报错
[root@localhost opt]# rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
warning: mysql-community-server-5.7.30-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
error: Failed dependencies:
/usr/bin/perl is needed by mysql-community-server-5.7.30-1.el7.x86_64
libaio.so.1()(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64
libaio.so.1(LIBAIO_0.1)(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64
libaio.so.1(LIBAIO_0.4)(64bit) is needed by mysql-community-server-5.7.30-1.el7.x86_64
mysql-community-client(x86-64) >= 5.7.9 is needed by mysql-community-server-5.7.30-1.el7.x86_64
net-tools is needed by mysql-community-server-5.7.30-1.el7.x86_64
perl(Getopt::Long) is needed by mysql-community-server-5.7.30-1.el7.x86_64
perl(strict) is needed by mysql-community-server-5.7.30-1.el7.x86_64
安装依赖后继续安装(已经在本地,要挂载)详见
一、下载地址https://pkgs.org/download
二、本地光盘挂载详见网址
https://www.php.cn/blog/detail/21923.html
在执行

  1. yum install libaio
  2. yum install net-tools
  3. yum search perl
  4. yum search libaio
  5. yum search net-tools
  6. yum -y install perl.x86_64
  7. yum install -y libaio.x86_64
  8. yum -y install net-tools.x86_6

再执行

  1. rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm

安装完成后启动mysql

  1. [root@localhost opt]# tum install libaio
  2. -bash: tum: command not found
  3. [root@localhost opt]# service mysqld start
  4. Redirecting to /bin/systemctl start mysqld.service
  5. [root@localhost opt]# mysql
  6. ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
  7. [root@localhost opt]# mysql -u root -p
  8. Enter password:
  9. Welcome to the MySQL monitor. Commands end with ; or \g.
  10. Your MySQL connection id is 3
  11. Server version: 5.7.30
  12. Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
  13. Oracle is a registered trademark of Oracle Corporation and/or its
  14. affiliates. Other names may be trademarks of their respective
  15. owners.
  16. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  17. mysql> exit
  18. Bye
root的mysql初始密码在/var/log/mysqld.log文件里


修改密码

  1. # 修改密码,密码强度字母数字大小写符号,否则报错
  2. mysql> alter user 'root'@'localhost' identified by '123456abc';
  3. ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
  4. mysql> alter user 'root'@'localhost' identified by '123456aB?';
  5. Query OK, 0 rows affected (0.00 sec)
  6. # 使密码生效
  7. flush privileges;
  8. # 允许以root身份远程登录mysql
  9. GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456aB?' WITH GRANT OPTION;

ok,本地登录正常
Navicat for mysql 远程连接 mySql数据库10061错误问题
进入/etc/my.cnf这个文件看看吧,
网上搜的
“发现bind-address=127.0.0.1 居然在这个文件中,便修改:

修改bind-address = 127.0.0.1

为 bind-address = 0.0.0.0

:wq —保存退出 ”

实际文本中并没有bind-address=这一行
然后新增bind-address = 0.0.0.0 保存退出重启mysqld

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议