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 输入密码即可连接
创建
mysql> CREATE USER 'aa'@'%' IDENTIFIED BY '1234';
Query OK, 0 rows affected (0.00 sec)
生效
mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
[root@localhost my.cnf.d]# service mysqld restart
Redirecting to /bin/systemctl restart mysqld.service
yum安装时出现state:sleeping pid:2091….
解决方法
rm -f /var/run/yum.pid 2091
在安装,未报错
很慢地址: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用户登录到数据库进行用户创建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
在执行
yum install libaio
yum install net-tools
yum search perl
yum search libaio
yum search net-tools
yum -y install perl.x86_64
yum install -y libaio.x86_64
yum -y install net-tools.x86_6
rpm -ivh mysql-community-server-5.7.30-1.el7.x86_64.rpm
安装完成后启动mysql
[root@localhost opt]# tum install libaio
-bash: tum: command not found
[root@localhost opt]# service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@localhost opt]# mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[root@localhost opt]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.30
Copyright (c) 2000, 2020, 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.
mysql> exit
Bye
修改密码
# 修改密码,密码强度字母数字大小写符号,否则报错
mysql> alter user 'root'@'localhost' identified by '123456abc';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> alter user 'root'@'localhost' identified by '123456aB?';
Query OK, 0 rows affected (0.00 sec)
# 使密码生效
flush privileges;
# 允许以root身份远程登录mysql
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