centos上利用yum安装mysql安装图解

合集下载

centos7环境使用mysql离线安装包安装mysql5.7

centos7环境使用mysql离线安装包安装mysql5.7

centos7环境使⽤mysql离线安装包安装mysql5.7服务器环境:centos7 x64需要安装mysql5.7+⼀、卸载CentOS7系统⾃带mariadb# 查看系统⾃带的Mariadb[root@CDH-141 ~]# rpm -qa|grep mariadbmariadb-libs-5.5.44-2.el7.centos.x86_64# 卸载系统⾃带的Mariadb(rpm -e --nodeps)[root@CDH-141 ~]# rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64# 删除etc⽬录下的f[root@CDH-141 ~]# rm /etc/f⼆、检查mysql是否存在# 检查mysql是否存在[root@CDH-141 ~]# rpm -qa | grep mysql[root@CDH-141 ~]#三、查看⽤户和组是否存在1)检查mysql组合⽤户是否存在# 检查mysql组和⽤户是否存在,如⽆则创建[root@CDH-141 ~]# cat /etc/group | grep mysql[root@CDH-141 ~]# cat /etc/passwd | grep mysql# 查询全部⽤户(只是做记录,没必要执⾏)[root@CDH-141 ~]# cat /etc/passwd|grep -v nologin|grep -v halt|grep -v shutdown|awk -F ":" '{print $1 "|" $3 "1" $4}' | moreroot|010sync|510flume|9921989hdfs|9911988zookeeper|9891986llama|9881985httpfs|9871984mapred|9861983sqoop|9851982yarn|9841981kms|9831980hive|9821979oozie|9801977hbase|9781975impala|9761973hue|9741971wlaqzc2018|100111001[root@CDH-141 mysql]#2)若不存在,则创建mysql组和⽤户# 创建mysql⽤户组[root@CDH-141 ~]# groupadd mysql# 创建⼀个⽤户名为mysql的⽤户,并加⼊mysql⽤户组[root@CDH-141 ~]# useradd -g mysql mysql# 制定password 为111111 (⽤户mysql的密码)[root@CDH-141 ~]# passwd mysqlChanging password for user mysql.New password:BAD PASSWORD: The password is a palindromeRetype new password:passwd: all authentication tokens updated successfully.四、下载mysql离线安装包tar⽂件官⽹下载地址:版本选择,可以选择⼀下两种⽅式:1)使⽤Red Hat Enterprise LinuxSelect Version:5.7.35Select Operating System:Red Hat Enterprise Linux / Oracle LinuxSelect OS Version:Red Hat Enterprise Linux 7 / Oracle Linux 7 (x86, 64-bit)列表中下载:Compressed TAR Archive:(mysql-5.7.35-el7-x86_64.tar.gz)2)使⽤Linux - GenericSelect Version:5.7.35Select Operating System:Linux - GenericSelect OS Version:Linux - Generic (glibc 2.12) (x86, 64-bit)列表中下载:Compressed TAR Archive:(mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz)【本⽂中使⽤的是这个版本】注意:上边两种⽅式找mysql离线安装包的⽅式都可以。

CentOS7安装MySQL8.0小计

CentOS7安装MySQL8.0小计

CentOS7安装MySQL8.0⼩计之前讲配置⽂件和权限的时候有很多MySQL8的知识,有同志说安装不太⼀样,希望发个⽂,我这边简单演⽰⼀下1.下载MySQL提供的CentOS7的yum源官⽅⽂档:<>过程中有不太懂的可以看我之前写的这篇⽂章:<>地址:安装yum源:yum install centos7.mysql.rpm -y安装MySQL8.0 yum install mysql-community-server -y启动mysql systemctl start mysqld设置开机启动mysql systemctl enable mysqld2.查看初始密码cat /var/log/mysqld.log | grep "password"安全初始化mysql_secure_installation3.权限相关详细可以查看上次写的⽂章:⽤root账号登录mysql -uroot -p创建⽤户dnt create user dnt@'%' identified by '含⼤⼩写字母+数字的密码';查看当前有哪些⽤户select user,authentication_string,host from er;给⽤户dnt分配数据库dotnetcrazy的所有权限grant all on dotnetcrazy.* to dnt;刷新权限flush privileges;显⽰新⽤户有哪些权限show grants for dnt;4.root权限去修改/etc/f在[mysqld]选项下新增:bind-address=0.0.0.0开放3306端⼝的远程访问权限:firewall-cmd --zone=public --add-port=3306/tcp --permanent刷新防⽕墙规则firewall-cmd --reload重启MySQL:systemctl restart mysqld测试1.安装附录# 下载yum源(curl是系统⾃带的)# curl https:////mysql80-community-release-el7-3.noarch.rpm > centos7.mysql.rpm[root@localhost dnt] curl https:////mysql80-community-release-el7-3.noarch.rpm > centos7.mysql.rpm% Total % Received % Xferd Average Speed Time Time Time CurrentDload Upload Total Spent Left Speed100 26024 100 26024 0 0 38150 0 --:--:-- --:--:-- --:--:-- 38158[root@localhost dnt]# lscentos7.mysql.rpm# 安装MySQL的yum源# yum install centos7.mysql.rpm -y[root@localhost dnt] yum install centos7.mysql.rpm -y已加载插件:fastestmirror正在检查 centos7.mysql.rpm: mysql80-community-release-el7-3.noarchcentos7.mysql.rpm 将被安装正在解决依赖关系--> 正在检查事务---> 软件包 mysql80-community-release.noarch.0.el7-3 将被安装--> 解决依赖关系完成依赖关系解决========================================================================================================== Package 架构版本源⼤⼩==========================================================================================================正在安装:mysql80-community-release noarch el7-3 /centos7.mysql 31 k事务概要==========================================================================================================安装 1 软件包总计:31 k安装⼤⼩:31 kDownloading packages:Running transaction checkRunning transaction testTransaction test succeededRunning transaction正在安装 : mysql80-community-release-el7-3.noarch 1/1验证中 : mysql80-community-release-el7-3.noarch 1/1已安装:mysql80-community-release.noarch 0:el7-3完毕!# 安装MySQL8.0# yum install mysql-community-server -y[root@localhost dnt] yum install mysql-community-server -y已加载插件:fastestmirrorLoading mirror speeds from cached hostfile* base: * extras: * updates: base | 3.6 kB 00:00:00extras | 3.4 kB 00:00:00mysql-connectors-community | 2.5 kB 00:00:00mysql-tools-community | 2.5 kB 00:00:00mysql80-community | 2.5 kB 00:00:00updates | 3.4 kB 00:00:00(1/3): mysql-connectors-community/x86_64/primary_db | 41 kB 00:00:00(2/3): mysql80-community/x86_64/primary_db | 70 kB 00:00:00(3/3): mysql-tools-community/x86_64/primary_db | 58 kB 00:00:00正在解决依赖关系--> 正在检查事务---> 软件包 mysql-community-server.x86_64.0.8.0.16-2.el7 将被安装--> 正在处理依赖关系 mysql-community-common(x86-64) = 8.0.16-2.el7,它被软件包 mysql-community-server-8.0.16-2.el7.x86_64 需要--> 正在处理依赖关系 mysql-community-client(x86-64) >= 8.0.11,它被软件包 mysql-community-server-8.0.16-2.el7.x86_64 需要--> 正在处理依赖关系 net-tools,它被软件包 mysql-community-server-8.0.16-2.el7.x86_64 需要--> 正在检查事务---> 软件包 mysql-community-client.x86_64.0.8.0.16-2.el7 将被安装--> 正在处理依赖关系 mysql-community-libs(x86-64) >= 8.0.11,它被软件包 mysql-community-client-8.0.16-2.el7.x86_64 需要---> 软件包 mysql-community-common.x86_64.0.8.0.16-2.el7 将被安装---> 软件包 net-tools.x86_64.0.2.0-0.24.20131004git.el7 将被安装--> 正在检查事务---> 软件包 mariadb-libs.x86_64.1.5.5.60-1.el7_5 将被取代--> 正在处理依赖关系 libmysqlclient.so.18()(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要--> 正在处理依赖关系 libmysqlclient.so.18(libmysqlclient_18)(64bit),它被软件包 2:postfix-2.10.1-7.el7.x86_64 需要---> 软件包 mysql-community-libs.x86_64.0.8.0.16-2.el7 将被舍弃--> 正在检查事务---> 软件包 mysql-community-libs-compat.x86_64.0.8.0.16-2.el7 将被舍弃--> 解决依赖关系完成依赖关系解决========================================================================================================== Package 架构版本源⼤⼩==========================================================================================================正在安装:mysql-community-libs x86_64 8.0.16-2.el7 mysql80-community 3.0 M替换 mariadb-libs.x86_64 1:5.5.60-1.el7_5mysql-community-libs-compat x86_64 8.0.16-2.el7 mysql80-community 2.1 M替换 mariadb-libs.x86_64 1:5.5.60-1.el7_5mysql-community-server x86_64 8.0.16-2.el7 mysql80-community 403 M为依赖⽽安装:mysql-community-client x86_64 8.0.16-2.el7 mysql80-community 32 Mmysql-community-common x86_64 8.0.16-2.el7 mysql80-community 575 knet-tools x86_64 2.0-0.24.20131004git.el7 base 306 k事务概要==========================================================================================================安装 3 软件包 (+3 依赖软件包)总下载量:441 MDownloading packages:警告:/var/cache/yum/x86_64/7/mysql80-community/packages/mysql-community-common-8.0.16-2.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY mysql-community-common-8.0.16-2.el7.x86_64.rpm 的公钥尚未安装(1/6): mysql-community-common-8.0.16-2.el7.x86_64.rpm | 575 kB 00:00:00(2/6): mysql-community-libs-8.0.16-2.el7.x86_64.rpm | 3.0 MB 00:00:00(3/6): mysql-community-libs-compat-8.0.16-2.el7.x86_64.rpm | 2.1 MB 00:00:00(4/6): net-tools-2.0-0.24.20131004git.el7.x86_64.rpm | 306 kB 00:00:00(5/6): mysql-community-client-8.0.16-2.el7.x86_64.rpm | 32 MB 00:00:14(6/6): mysql-community-server-8.0.16-2.el7.x86_64.rpm | 403 MB 00:01:08-------------------------------------------------------------------------------------------------------------------总计 6.2 MB/s | 441 MB 00:01:10从 file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql 检索密钥导⼊ GPG key 0x5072E1F5:⽤户ID : "MySQL Release Engineering <mysql-build@>"指纹 : a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5软件包 : mysql80-community-release-el7-3.noarch (installed)来⾃ : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysqlRunning transaction checkRunning transaction testTransaction test succeededRunning transaction正在安装 : mysql-community-common-8.0.16-2.el7.x86_64 1/7正在安装 : mysql-community-libs-8.0.16-2.el7.x86_64 2/7正在安装 : mysql-community-client-8.0.16-2.el7.x86_64 3/7正在安装 : net-tools-2.0-0.24.20131004git.el7.x86_64 4/7正在安装 : mysql-community-server-8.0.16-2.el7.x86_64 5/7正在安装 : mysql-community-libs-compat-8.0.16-2.el7.x86_64 6/7正在删除 : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 7/7验证中 : mysql-community-libs-8.0.16-2.el7.x86_64 1/7验证中 : net-tools-2.0-0.24.20131004git.el7.x86_64 2/7验证中 : mysql-community-libs-compat-8.0.16-2.el7.x86_64 3/7验证中 : mysql-community-client-8.0.16-2.el7.x86_64 4/7验证中 : mysql-community-common-8.0.16-2.el7.x86_64 5/7验证中 : mysql-community-server-8.0.16-2.el7.x86_64 6/7验证中 : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 7/7已安装:mysql-community-libs.x86_64 0:8.0.16-2.el7 mysql-community-libs-compat.x86_64 0:8.0.16-2.el7mysql-community-server.x86_64 0:8.0.16-2.el7作为依赖被安装:mysql-community-client.x86_64 0:8.0.16-2.el7 mysql-community-common.x86_64 0:8.0.16-2.el7net-tools.x86_64 0:2.0-0.24.20131004git.el7替代:mariadb-libs.x86_64 1:5.5.60-1.el7_5完毕!# 启动mysql# systemctl start mysqld[root@localhost dnt] systemctl start mysqld[root@localhost dnt] pstree | grep mysql|-mysqld---37*[{mysqld}]# 设置开机启动mysql# systemctl enable mysqld[root@localhost dnt] systemctl enable mysqld[root@localhost dnt] rebootConnection closing...Socket close.Connection closed by foreign host.Disconnected from remote host(MySQL_CentOS) at 10:56:42.Connecting to 192.168.36.205:22...Connection established.To escape to local shell, press 'Ctrl+Alt+]'.WARNING! The remote SSH server rejected X11 forwarding request.Last login: Wed May 15 10:35:07 2019 from 192.168.36.144[dnt@localhost ~]$ pstree | grep mysql|-mysqld---37*[{mysqld}]# 查看mysql的状态# systemctl status mysqld[dnt@localhost ~]$ systemctl status mysqld● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since 三 2019-05-15 10:57:26 CST; 1min 3s agoDocs: man:mysqld(8)/doc/refman/en/using-systemd.htmlProcess: 3934 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)Main PID: 3969 (mysqld)Status: "SERVER_OPERATING"CGroup: /system.slice/mysqld.service└─3969 /usr/sbin/mysqld2.初始化配置附录# 查看初始密码# cat /var/log/mysqld.log | grep "password"[dnt@localhost ~]$ cat /var/log/mysqld.log | grep "password"2019-05-15T02:55:51.132377Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: wI>X.(tHE5&e # 安全初始化# mysql_secure_installation[dnt@localhost ~]$ mysql_secure_installationSecuring the MySQL server deployment.Enter password for user root:The 'validate_password' component is installed on the server.The subsequent steps will run with the existing configurationof the component.Using existing password for root.Estimated strength of the password: 100Change 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) : ySuccess.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) : ySuccess.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) : ySuccess.All done!3.权限附录# ⽤root账号登录# mysql -uroot -p[dnt@localhost ~]$ mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 38Server version: 8.0.16 MySQL Community Server - GPLCopyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.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.# show databases;mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || mysql || performance_schema || sys |+--------------------+4 rows in set (0.00 sec)# 创建⽤户dnt# create user dnt@'%' identified by '含⼤⼩写字母+数字的密码';mysql> create user dnt@'%' identified by '含⼤⼩写字母+数字的密码';Query OK, 0 rows affected (0.06 sec)# 查看当前有哪些⽤户# select user,authentication_string,host from er;mysql> select user,authentication_string,host from er;+------------------+------------------------------------------------------------------------+-----------+| user | authentication_string | host |+------------------+------------------------------------------------------------------------+-----------+| dnt | $A$005$yOK}8VFp< LE0BLBPFmeTy2vi8Q1JdmkhkPkaWBilxWYW2/jSsJ4OEa7B | % || schema | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost | | mysql.session | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost | | mysql.sys | $A$005$THISISACOMBINATIONOFINVALIDSALTANDPASSWORDTHATMUSTNEVERBRBEUSED | localhost | | root | $A$005$yAn@!RwTRzRLdyRrHMdoneUh7pdKEJVFUl9LHdG5MHeL.gdovFMI7z22 | localhost |+------------------+------------------------------------------------------------------------+-----------+5 rows in set (0.00 sec)# 创建⼀个数据库# create database dotnetcrazy charset=utf8;mysql> create database dotnetcrazy charset=utf8;Query OK, 1 row affected, 1 warning (0.71 sec)mysql> show databases;+--------------------+| Database |+--------------------+| dotnetcrazy || information_schema || mysql || performance_schema || sys |+--------------------+5 rows in set (0.00 sec)# 给⽤户dnt分配数据库dotnetcrazy的所有权限# grant all on dotnetcrazy.* to dnt;mysql> grant all on dotnetcrazy.* to dnt;Query OK, 0 rows affected (0.69 sec)# 刷新权限# flush privileges;mysql> flush privileges;Query OK, 0 rows affected (0.59 sec)# 显⽰新⽤户有哪些权限# show grants for dnt;mysql> show grants for dnt;+------------------------------------------------------+| Grants for dnt@% |+------------------------------------------------------+| GRANT USAGE ON *.* TO `dnt`@`%` || GRANT ALL PRIVILEGES ON `dotnetcrazy`.* TO `dnt`@`%` |+------------------------------------------------------+2 rows in set (0.00 sec)mysql> exitBye# ⽤新增⽤户登录# mysql -udnt -p[dnt@localhost ~]$ mysql -udnt -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 39Server version: 8.0.16 MySQL Community Server - GPLCopyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.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.# show databases;mysql> show databases;+--------------------+| Database |+--------------------+| dotnetcrazy || information_schema |+--------------------+2 rows in set (0.01 sec)4.配置附录[dnt@localhost ~]$ su密码:[root@localhost dnt]# ls /etc/ | grep myff.d[root@localhost dnt]# ls /etc/f.d/# 修改配置,运⾏远程登录[root@localhost dnt]# vi /etc/f[root@localhost dnt]# cat /etc/f[mysqld]bind-address=0.0.0.0 # 新增内容datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.socklog-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid# 查看⼀下防⽕墙状态# systemctl status firewalld[root@localhost dnt] systemctl status firewalld● firewalld.service - firewalld - dynamic firewall daemonLoaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)Active: active (running) since 三 2019-05-15 17:37:49 CST; 28min agoDocs: man:firewalld(1)Main PID: 3467 (firewalld)CGroup: /system.slice/firewalld.service└─3467 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid5⽉ 15 17:37:47 localhost.localdomain systemd[1]: Starting firewalld - dynamic firewall daemon... 5⽉ 15 17:37:49 localhost.localdomain systemd[1]: Started firewalld - dynamic firewall daemon. # 开放3306端⼝的远程访问权限# firewall-cmd --zone=public --add-port=3306/tcp --permanent[root@localhost dnt]# firewall-cmd --zone=public --add-port=3306/tcp --permanentsuccess# 刷新防⽕墙规则# firewall-cmd --reload[root@localhost dnt]# firewall-cmd --reloadsuccess# 重启MySQL# systemctl restart mysqld[root@localhost dnt]# systemctl restart mysqld。

CentOS6.3系统Yum安装php+spawn-fcgi+nginx和数据库mysql详细教程

CentOS6.3系统Yum安装php+spawn-fcgi+nginx和数据库mysql详细教程

rpm 软件(yum 的命令详解请自行) yum 默认只提供了官方给出的软件仓库,如果要使用非官方的软件还需要安装非官方的 yum 仓库,yum 仓库的配置文件位于/etc/yum.repo.d/*.repo 推 荐 的 非 官 方 yum 仓 库 就 是 fadora 项 目 下 的 EPEL 仓 库 , 其 网 址 是 : /wiki/EPEL ,安装并配置此 yum 仓库后可以使用更多的非官方提供 的最新软件和新功能 下载此仓库的 rpm 安装文件并安装(注意选择跟自己系统对应的版本,目前是 centos5、 centos6 两个版本): [root@localhost /]# wget /fedora-e ... ease-6-7.noarch.rpm [root@localhost /]# rpm -ivh epel-release-6-7.noarch.rpm 此时 fadoraproject 的 yum 仓库就可以使用了,可以从中使用更多的软件了。
pid
/var/run/nginx.pid;
events { worker_connections 1024;
}
http {
include
/etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"';

CentOS7离线安装MySQL的教程详解

CentOS7离线安装MySQL的教程详解

CentOS7离线安装MySQL的教程详解1.删除原有的mariadb,不然mysql装不进去mariadb-libs-5.5.52-1.el7.x86_64rpm -qa|grep mariadbrpm -e --nodeps mariadb-libs直接下载mysql-5.7.21-1.el7.x86_64.rpm-bundle.tar,所有的rpm包都在⾥⾯rpm -ivh mysql-community-common-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-devel-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-libs-compat-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-client-5.7.21-1.el7.x86_64.rpmrpm -ivh mysql-community-server-5.7.21-1.el7.x86_64.rpm⾄此,mysql5.7所有⽂件安装完毕,接下来就是开启服务测试了。

1.⾸先关闭mysql服务:service mysqld stop2.然后修改配置⽂件:vim /etc/f3.接下来加⼊⼀句代码即可空密码登录mysql:# Disabling symbolic-links is recommended to prevent assorted security risksskip-grant-tables #添加这句话,这时候登⼊mysql就不需要密码symbolic-links=04.开启mysql服务:service mysqld start5.空密码登录mysql:mysql -u root -p #输⼊命令回车进⼊,出现输⼊密码提⽰直接回车6.设置mysql密码:mysql> set password for root@localhost = password('123456');ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statementmysql> flush privileges; #更新权限Query OK, 0 rows affected (0.00 sec)mysql> set password for root@localhost = password('123456');Query OK, 0 rows affected, 1 warning (0.00 sec)mysql>flush privileges; #更新权限mysql>quit; #退出service mysqld stop # 停⽌mysql服务, 恢复mysql配置vim /etc/f #修改配置⽂件# Disabling symbolic-links is recommended to prevent assorted security risks# skip-grant-tables # 注释掉这句话symbolic-links=0service mysqld start # 启动mysql服务mysql -uroot -p # 输⼊新密码登录7.设置mysql开机⾃启:systemctl enable mysqld总结以上所述是⼩编给⼤家介绍的CentOS7离线安装MySQL的教程,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。

CentOS7安装MYSQL5.7.7

CentOS7安装MYSQL5.7.7
1
#groupadd mysql
#useradd-r-g mysql mysql---新建msyql用户禁止登录shell
2
# cd /usr/local/---切换到存放源码包所在目录(这里也是安装目录)
# tar -xvf mysql-5.7.7-m16-linux-glibc2.5-x86_64.tar.gz---在当前目录解压通用编译包
1、初始化数据库时不再使用“--mysql_install_db”而是使用了“--initialize”或是”--initialize-insecure”,区别在于“--initialize”会生成一个随机密码而”--initialize-insecure”不会生成密码。
2、不在生成.mysql_secret文件;
3、不再创建匿名用户MySQL账户;
4、不再创建测试数据库。
编译
1
1).下载cmake-3.2.1.tar.gz---新版的MySQL用CMAKE编译安装
/download/
2).下载ncurses-5.9.tar.gz---安装MySQL时需要
ftp:///gnu/ncurses/
-DMYSQL_DATADIR=/usr/local/mysql/data/\---数据库目录
-DDEFAULT_CHARSET=utf8\---字符集支持
-DDEFAULT_COLLATION=utf8_general_ci\---字符集支持
-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock\---指定mysql.sock位置
介绍:MySQL的安装方法有多种,如yum安装,rpm包安装,rpm源码编译安装,源码编译安装,通用预编译包安装。其中yum安装和rpm包安装比较简单,软件安装时会自动默认设置,但可定制性弱版也较旧。源码包编译安装可定制性强版本也新。下面是通用预编译包安装和源码编译安装的方法,MySQL的版本为最新的5.7.7版。在MySQL5.7.7中有一些新的特性如:

CentOS 6.0安装MySQL 5.6及配置

CentOS 6.0安装MySQL 5.6及配置

CentOS 6.0安装MySQL 5.6及配置从今年3月份开始mysql官网开始发布相关的5.6系列的各个版本,对于mysql5.6系列的版本对一起的版本进行了全局性的细节性加强;个人感觉,以下是在虚拟机中配置的mysql5.6.10源码安装的过程分享记录下:一、必要软件包安装:[root@mysql5~]#yum -y install gcc gcc-c++ gcc-g77 autoconf automake zlib* fiex* libxml* ncurse s-devel libmcrypt* libtool-ltdl-devel* make cmake二、编译安装:[root@mysql5 ~]# groupadd mysql[root@mysql5 ~]# useradd -r -g mysql mysql[root@mysql5 ~]# lsanaconda-ks.cfg install.log install.log.syslog mysql-5.6.10.tar.gz[root@mysql5 ~]# cd /usr/local/[root@mysql5 local]# lsbin etc games include lib libexec sbin share src[root@mysql5 local]# cp /root/mysql-5.6.10.tar.gz /usr/local/[root@mysql5 local]# lltotal 34468drwxr-xr-x 2 root root 4096 Jan 27 2010 bindrwxr-xr-x 2 root root 4096 Jan 27 2010 etcdrwxr-xr-x 2 root root 4096 Jan 27 2010 gamesdrwxr-xr-x 2 root root 4096 Jan 27 2010 includedrwxr-xr-x 2 root root 4096 Jan 27 2010 libdrwxr-xr-x 2 root root 4096 Jan 27 2010 libexec-rw-r--r-- 1 root root 35174149 Apr 17 00:55 mysql-5.6.10.tar.gzdrwxr-xr-x 2 root root 4096 Jan 27 2010 sbindrwxr-xr-x 4 root root 4096 Apr 17 00:32 sharedrwxr-xr-x 2 root root 4096 Jan 27 2010 src[root@mysql5 local]# tar -zxvf mysql-5.6.10.tar.gz[root@mysql5 local]# cd mysql-5.6.10[root@mysql5 local]# cmake . ###编译报如下错误暂不管[ 63%] Building CXX object sql/CMakeFiles/sql.dir/sql_.o/root/mysql-5.6.13/sql/sql_: In member function ‘void Optimize_table_order::best_access_path(JOIN_TAB*, table_map, uint, bool, double, POSITION*, POSITION*)’:/root/mysql-5.6.13/sql/sql_:431: warning: ‘loose_scan_opt.Loose_scan_opt::best_loose_scan_start_key’may be used uninitialized in this function/root/mysql-5.6.13/sql/sql_:431: warning: ‘loose_scan_opt.Loose_scan_opt::best_max_loose_keypart’may be used uninitialized in this function/root/mysql-5.6.13/sql/sql_:431: warning: ‘loose_scan_opt.Loose_scan_opt::best_loose_scan_records’may be used uninitialized in this function/root/mysql-5.6.13/sql/sql_:431: warning: ‘loose_scan_opt.Loose_scan_opt::best_loose_scan_key’may be used uninitialized in this function/root/mysql-5.6.13/sql/sql_:431: warning: ‘loose_scan_opt.Loose_scan_opt::quick_max_loose_keypart’may be used uninitialized in this function[root@mysql5 local]# make && make install三、配置MySQL[root@mysql5 mysql-5.6.10]# chown -R mysql.mysql /usr/local/mysql[root@mysql5 mysql-5.6.10]#[root@mysql5 mysql-5.6.10]# cd /usr/local/mysql/scripts/[root@mysql5 scripts]# ./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/dataInstalling MySQL system tables...2013-04-17 01:26:58 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2013-04-17 01:26:58 18715 [Note] InnoDB: The InnoDB memory heap is disabled2013-04-17 01:26:58 18715 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2013-04-17 01:26:58 18715 [Note] InnoDB: Compressed tables use zlib 1.2.32013-04-17 01:26:58 18715 [Note] InnoDB: CPU does not support crc32 instructions2013-04-17 01:26:58 18715 [Note] InnoDB: Initializing buffer pool, size = 128.0M2013-04-17 01:26:58 18715 [Note] InnoDB: Completed initialization of buffer pool2013-04-17 01:26:58 18715 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!2013-04-17 01:26:59 18715 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB2013-04-17 01:26:59 18715 [Note] InnoDB: Database physically writes the file full: wait...2013-04-17 01:26:59 18715 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB2013-04-17 01:26:59 18715 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB2013-04-17 01:26:59 18715 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0 2013-04-17 01:26:59 18715 [Warning] InnoDB: New log files created, LSN=457812013-04-17 01:26:59 18715 [Note] InnoDB: Doublewrite buffer not found: creating new2013-04-17 01:26:59 18715 [Note] InnoDB: Doublewrite buffer created2013-04-17 01:26:59 18715 [Note] InnoDB: 128 rollback segment(s) are active.2013-04-17 01:26:59 18715 [Warning] InnoDB: Creating foreign key constraint system tables. 2013-04-17 01:26:59 18715 [Note] InnoDB: Foreign key constraint system tables created2013-04-17 01:26:59 18715 [Note] InnoDB: Creating tablespace and datafile system tables. 2013-04-17 01:26:59 18715 [Note] InnoDB: Tablespace and datafile system tables created.2013-04-17 01:26:59 18715 [Note] InnoDB: Waiting for purge to start2013-04-17 01:26:59 18715 [Note] InnoDB: 1.2.10 started; log sequence number 02013-04-17 01:26:59 18715 [Note] Binlog end2013-04-17 01:26:59 18715 [Note] InnoDB: FTS optimize thread exiting.2013-04-17 01:26:59 18715 [Note] InnoDB: Starting shutdown...2013-04-17 01:27:00 18715 [Note] InnoDB: Shutdown completed; log sequence number 1625977 OKFilling help tables...2013-04-17 01:27:00 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).2013-04-17 01:27:00 18738 [Note] InnoDB: The InnoDB memory heap is disabled2013-04-17 01:27:00 18738 [Note] InnoDB: Mutexes and rw_locks use InnoDB's own implementation2013-04-17 01:27:00 18738 [Note] InnoDB: Compressed tables use zlib 1.2.32013-04-17 01:27:00 18738 [Note] InnoDB: CPU does not support crc32 instructions2013-04-17 01:27:00 18738 [Note] InnoDB: Initializing buffer pool, size = 128.0M2013-04-17 01:27:00 18738 [Note] InnoDB: Completed initialization of buffer pool2013-04-17 01:27:00 18738 [Note] InnoDB: Highest supported file format is Barracuda.2013-04-17 01:27:00 18738 [Note] InnoDB: 128 rollback segment(s) are active.2013-04-17 01:27:00 18738 [Note] InnoDB: Waiting for purge to start2013-04-17 01:27:01 18738 [Note] InnoDB: 1.2.10 started; log sequence number 16259772013-04-17 01:27:01 18738 [Note] Binlog end2013-04-17 01:27:01 18738 [Note] InnoDB: FTS optimize thread exiting.2013-04-17 01:27:01 18738 [Note] InnoDB: Starting shutdown...2013-04-17 01:27:02 18738 [Note] InnoDB: Shutdown completed; log sequence number 1625987 OKTo start mysqld at boot time you have to copysupport-files/mysql.server to the right place for your systemPLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !To do so, start the server, then issue the following commands:/usr/local/mysql/bin/mysqladmin -u root password 'new-password'/usr/local/mysql/bin/mysqladmin -u root -h mysql5.6 password 'new-password'Alternatively you can run:/usr/local/mysql/bin/mysql_secure_installationwhich will also give you the option of removing the testdatabases and anonymous user created by default. This isstrongly recommended for production servers.See the manual for more instructions.You can start the MySQL daemon with:cd . ; /usr/local/mysql/bin/mysqld_safe &You can test the MySQL daemon with mysql-test-run.plcd mysql-test ; perl mysql-test-run.plPlease report any problems with the ./bin/mysqlbug script!The latest information about MySQL is available on the web at Support MySQL by buying support/licenses at New default config file was created as /usr/local/mysql/f and will be used by default by the server when you start it.You may edit this file to change server settingsWARNING: Default config file /etc/f exists on the systemThis file will be read by default by the MySQL serverIf you do not want to use this, either remove it, or use the--defaults-file argument to mysqld_safe when starting the server[root@mysql5 scripts]#[root@mysql5 scripts]# cd /usr/local/mysql/support-files/[root@mysql5 support-files]# cp mysql.server /etc/rc.d/init.d/mysql cp: overwrite `/etc/rc.d/init.d/mysql'? y[root@mysql5 support-files]# cp f /etc/fcp: overwrite `/etc/f'? y[root@mysql5 support-files]#[root@mysql5 support-files]# chkconfig -add mysql-add: unknown option[root@mysql5 support-files]# chkconfig --add mysql[root@mysql5 support-files]# chkconfig mysql on[root@mysql5 support-files]# service mysql startStarting MySQL. [ OK ] [root@mysql5 support-files]#[root@mysql5 data]# mysql -u mysql -p -S /tmp/mysql.sockEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 1Server version: 5.6.10 Source distributionType 'help;' or '\h' for help. Type '\c' to clear the buffer.mysql>mysql> status;--------------mysql Ver 14.12 Distrib 5.0.77, for RedHat-linux-gnu (i686) using readline 5.1Connection id: 1Current database:Current user: mysql@localhostSSL: Not in useCurrent pager: stdoutUsing outfile: ''Using delimiter: ;Server version: 5.6.10 Source distributionProtocol version: 10Connection: Localhost via UNIX socketServer characterset: latin1Db characterset: latin1Client characterset: latin1Conn. characterset: latin1UNIX socket: /tmp/mysql.sockUptime: 3 min 38 secThreads: 1 Questions: 5 Slow queries: 0 Opens: 67 Flush tables: 1 Open tables: 60 Queries per second avg: 0.022--------------mysql>四、远程登录及常用命令1、mysql服务的启动和停止net stop mysqlnet start mysql2、本地登陆mysql及远程登录语法如下:mysql -u用户名-p用户密码键入命令mysql –uroot -p,回车后提示你输入密码,输入12345,然后回车即可进入到mysql 中了,mysql的提示符是:mysql>注意,如果是连接到另外的机器上,则需要加入一个参数-h机器IP但被远程登录的mysql服务器需增加登录账号,方法如下:mysql>GRANT ALL PRIVILEGES ON*.* TO USER1@’%’ IDENTIFIED BY ’password’mysql>FLUSH PRIVILEGES;3、增加新用户格式:grant 权限on 数据库.* to 用户名@登录主机identified by "密码"如,增加一个用户user1密码为password1,让其可以在本机上登录,并对所有数据库有查询、插入、修改、删除的权限。

CentOS8下MySQL8.0安装部署的方法

CentOS8下MySQL8.0安装部署的方法

CentOS8下MySQL8.0安装部署的⽅法MySQL 8正式版8.0.11已发布,官⽅表⽰MySQL8要⽐MySQL 5.7快2倍,还带来了⼤量的改进和更快的性能!到底谁最⽜呢?请看:MySQL 5.7 vs 8.0,哪个性能更⽜?Mysql8.0安装 (YUM⽅式)1、⾸先删除系统默认或之前可能安装的其他版本的mysql# for i in $(rpm -qa|grep mysql);do rpm -e $i --nodeps;done# rm -rf /var/lib/mysql && rm -rf /etc/f2、安装Mysql8.0 的yum资源库mysql80-community-release-el7-1.noarch.rpm# yum localinstall https:////mysql80-community-release-el7-1.noarch.rpm3、安装Mysql8.0# yum install mysql-community-server#启动MySQL服务器和MySQL的⾃动启动# systemctl start mysqld# systemctl enable mysqld# systemctl status mysqld[root@localhost opt]# netstat -lantp | grep 3306tcp6 0 0 :::33060 :::* LISTEN 25431/mysqldtcp6 0 0 :::3306 :::* LISTEN 25431/mysqld[root@localhost opt]# ps -aux | grep mysqldmysql 25431 0.8 17.2 1776932 350232 ? Ssl 16:24 0:01 /usr/sbin/mysqldroot 25672 0.0 0.0 112828 980 pts/1 S+ 16:28 0:00 grep --color=auto mysqld登录报错跳过密码登录,添加skip-grant-tables,然后重启MySQL服务。

mysql(4)-linux环境centos7安装mysql8.0.19详细安装步骤

mysql(4)-linux环境centos7安装mysql8.0.19详细安装步骤

mysql(4)-linux环境centos7安装mysql8.0.19详细安装步骤Centos7 Linux 上安装 MySQL8.0.191. 安装&解压压缩包到⽬标位置下载的⽂件应该是⼀个 mysql*.tar.xz 格式的压缩包,这⾥需要先对 .xz 解压解压:tar xvJf ***.tar.xz (注意:J是⼤写的字母)将解压出来的⽂件移动到 /usr/local/ 且修改原来的名字mysql-8.0.19-linux-glibc2.12-x86_64修改为mysqlmv mysql-8.0.19-linux-glibc2.12-x86_64 /usr/local/cd /usr/local/mv mysql-8.0.19-linux-glibc2.12-x86_64 mysql (给mysql-8.0.19-linux-glibc2.12-x86_64重命名)到这⾥我们就得到 MySQL的⽂件夹了,并且将他移动到了 /usr/local ⽬录下改名为 mysql 。

2. 新建mysql⽤户、组及⽬录在这⾥我们新建⼀个 mysql ⽤户组和⽤户⽤来运⾏ mysql,作⽤:可以提⾼系统的安全⾏性。

groupadd mysqluseradd -M -g mysql -s /sbin/nologin mysqlpasswd mysql理解:上⾯的命令第1句是新建⼀个⽤户组,第2句再新建⼀个⽤户并且不可以登录,不创建家⽬录,第3句命令给 mysql ⽤户修改密码。

3. 创建mysql数据仓库⽬录注意在根⽬录下新建cd /mkdir /data/mysql 数据仓库⽬录 (新建data⽂件夹以及mysql⽂件夹,⽤来存放mysql的数据仓库)sudo chown -R mysql.mysql /data理解:创建 /data ⽬录并且将⽬录属主设置为 mysql. (注意是mysql. 是点)或者sudo mkdir -p /data/mysqlsudo chown -R mysql.mysql /data4.接下来创建 mysql 的配置⽂件 /etc/f (备注:/etc/下我本来的⽂件是没有f的这是我新建的)sudo vim /etc/f原有的[mysqld]datadir=/var/lib/mysqlsocket=/var/lib/mysql/mysql.sock# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# Settings user and group are ignored when systemd is used.# If you need to run mysqld under a different user or group,# customize your systemd unit file for mariadb according to the# instructions in /wiki/Systemd[mysqld_safe]log-error=/var/log/mariadb/mariadb.logpid-file=/var/run/mariadb/mariadb.pid## include all files from the config directory#!includedir /etc/f.d1 # MySQL 配置⽂件,2 #参考:/zhangxinqi/21784073 # https:///lyq863987322/p/8074749.html替换成以下内容:# 数据库⽬录 /data/mysql[client]port=3306# mysql socket ⽂件存放地址socket=/tmp/mysql.sock# 默认字符集default-character-set=utf8[mysqld]server-id=1# 端⼝port=3306# 运⾏⽤户user=mysql# 最⼤连接max_connections=200socket=/tmp/mysql.sock# mysql 安装⽬录(解压后⽂件的⽬录)basedir=/usr/local/mysql# 数据⽬录(这⾥放在我们新建的 /data/mysql 下)datadir=/data/mysqlpid-file=/data/mysql/mysql.pidinit-connect='SET NAMES utf8'character-set-server=utf8# 数据库引擎default-storage-engine=INNODBlog_error=/data/mysql/mysql-error.logslow_query_log_file=/data/mysql/mysql-slow.log# 跳过验证密码(想跳过验证密码就放开即不注释不想跳过即会输⼊密码,那就注释掉)#skip-grant-tables[mysqldump]quickmax_allowed_packet=16MEOF到这⾥配置⽂件就建好了,上⾯是我⾃⼰的配置,在 mysql 启动的时候就会⾃动读取这个配置⽂件。

CENTOS7环境安装MySQL5.6(rpm_二进制_源代码编译三种方式)

CENTOS7环境安装MySQL5.6(rpm_二进制_源代码编译三种方式)

CENTOS7环境安装MySQL软件环境虚拟机:VMware® Workstation-10.0.1 build-1379776-Win Linux:Centos 7 X86_64MySQL Database: MySQL-5.6.24系统环境MySQL软件安装一、使用RPM安装。

安装采用RPM安装包安装。

下载mysql:/downloads/mysql/打开页面之后,在Select Platform:下选择linux Generic下载后的包为名称为:MySQL-5.6.24-1.linux_glibc2.5.x86_64.rpm-bundle.tar(一)卸载原有MySQL或者Mariadb安装程序1、CentOs7版本默认情况下安装了mariadb-libs,必须先卸载才可以继续安装MySql。

a) 查找以前是否安装mariadb-libs# rpm -qa | grep -i mariadb-libsb)卸载已经安装的mariadb-libs# yum remove mariadb-libs-5.5.41-2.el7_0.x86_642、查找以前是否安装MySQL# rpm -qa | grep -i mysql--说明已经有安装了MySQL程序a)停止mysql服务# sudo service mysql stop或者:# ps -A | grep mysql# kill -9 进程号b)删除之前安装的mysql# rpm -ve MySQL-server-5.6.24-1.linux_glibc2.5.x86_64# rpm -ve MySQL-client-5.6.24-1.linux_glibc2.5.x86_64c)查找之前老版本mysql的目录、并且删除老版本mysql的文件和库# find / -name mysql【查找结果如下】# find / -name mysql/var/lib/mysql/usr/lib64/mysql/usr/local/mysql/usr/local/mysql/data/mysql【删除对应的目录】# rm -rf /var/lib/mysql# rm -rf /usr/lib64/mysql# rm -rf /usr/local/mysql【删除配置文档】# rm -rf /etc/fd)再次查找机器是否安装mysql# rpm -qa|grep -i mysql【无结果,说明已经卸载彻底、接下来直接安装mysql即可】(二)下载和解压、安装【创建一个任意名称文件夹,如:rpm】# mkdir rpm# cd rpm【下载安装包的压缩文档】# wget /Downloads/MySQL-5.6/MySQL-5.6.17-1.el6.x8 6_64.rpm-bundle.tar# tar –xvf MySQL-5.6.17-1.el6.x86_64.rpm-bundle.tar【创建mysql用户和数据目录】#groupadd mysql#useradd -r -g mysql mysql#cd /usr/local#sudo mkdir mysql#cd mysql#sudo mkdir mysql#sudo chown -R mysql .#sudo chgrp -R mysql .【安装RPM包】#sudo rpm -ivh MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm如果出现错误:FATAL ERROR: please install the following Perl modules beforeexecuting ./scripts/mysql_install_db:Data::Dumper先用yum list 查找下module:# yum list|grep -i perl-modul*# yum install -y perl-Module-Install.noarch#rpm -ev MySQL-server-5.6.24-1.linux_glibc2.5.x86_64重新执行:#sudo rpm -ivh MySQL-server-5.6.24-1.linux_glibc2.5.x86_64.rpm【初始化MySql配置文件】#cp f /etc/f可以简单修改配置如下。

MySQL5.7在CentOS7上的安装

MySQL5.7在CentOS7上的安装

在CentOS7上安装MySQL5.7.9时间:2015-11-07 作者:dusuanyun系统版本:CentOS-7-x86_64-DVD-1503-01.iso 安装后不要升级!!!(我试过升级后安装MySQL不能启动)网络环境:虚拟机桥接,可以连接外网:安装方式:手动网络安装---仓库的方式需要的文件:如下图。

PDF文件为官方指导文件。

1.将mysql57-community-release-el7-7.noarch.rpm文件置于CentOS的Root家目录:[root@MySQL ~]# ll总用量16-rw-------. 1 root root 1665 11月7 10:49 anaconda-ks.cfg-rw-r--r--. 1 root root 8984 11月7 11:13 mysql57-community-release-el7-7.noarch.rpm2.开始安装:按照提示一步步安装即可[root@MySQL ~]# rpm -ivh mysql57-community-release-el7-7.noarch.rpm[root@MySQL ~]# yum install mysql-community-server3.查看支持当前系统的可以安装MySQL的其他组件:[root@MySQL ~]# yum --disablerepo=\* --enablerepo='mysql*-community*' list available4.查看安装后的MySQL的服务是否已经启动:[root@MySQL ~]# service mysqld statusRedirecting to /bin/systemctl status mysqld.servicemysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)Active: inactive (dead)5.没有启动,则启动MySQL服务:[root@MySQL ~]# service mysqld startRedirecting to /bin/systemctl start mysqld.service检查是否正常启动,[root@MySQL ~]# service mysqld statusRedirecting to /bin/systemctl status mysqld.servicemysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled)Active: active (running) si nce 六2015-11-07 11:24:02 CST; 14s agoProcess: 3157 ExecStart=/usr/sbin/mysqld --daemonize $MYSQLD_OPTS (code=exited, status=0/SUCCESS)6.查看安装MySQL后自动产生的随机Root密码:此Root密码是数据库的不是CentOS系统的[root@MySQL ~]# grep 'temporary password' /var/log/mysqld.log2015-11-07T03:23:44.719982Z 1 [Note] A temporary password is generated for root@localhost: JfHhiPk,n2Pw7.用随机密码登录MySQL并修改Root密码:[root@MySQL ~]# mysql -u root -pJfHhiPk,n2Pwmysql> use mysqlERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement. 密码必须满足复杂性的策略mysql> SET PASSWORD FOR 'root'@'localhost'= "pw57mysql";ERROR 1819 (HY000): Your password does not satisfy the current policy requirementsmysql> SET PASSWORD FOR 'root'@'localhost'= "PW57-mysql";Query OK, 0 rows affected (0.00 sec)mysql> exitBye8.用新的密码登录,修改MySQL表支持非本机连接:[root@MySQL ~]# mysql -u root -pPW57-mysqlmysql> use mysqlReading table information for completion of table and column namesYou can turn off this feature to get a quicker startup with -ADatabase changedmysql> select host, user from user; -----修改前+-----------+-----------+| host | user |+-----------+-----------+| localhost | mysql.sys || localhost | root |+-----------+-----------+2 rows in set (0.00 sec)mysql> update user set host = '%' where user = 'root'; ---修改Query OK, 1 row affected (0.00 sec)Rows matched: 1 Changed: 1 Warnings: 0mysql> select host, user from user; -----修改后+-----------+-----------+| host | user |+-----------+-----------+| % | root || localhost | mysql.sys |+-----------+-----------+2 rows in set (0.00 sec)mysql> flush privileges; ------刷新,让修改立即生效!Query OK, 0 rows affected (0.00 sec)mysql>Bye9.检查CentOS的防火墙设置:因为发现其他机器可以ping通,连数据库却不通。

yum安装mysql,yum安装指定版本的mysql

yum安装mysql,yum安装指定版本的mysql

yum安装mysql,yum安装指定版本的mysqlyum安装mysql:1. 查看有没有安装过yum list installed MySQL* (有存在要卸载yum remove MySQL*)rpm -qa | grep mysql*查看有没有安装包:yum list mysql*2. 安装mysql客户端yum -y install mysql安装mysql 服务器端yum -y install mysql-server mysql-devel3. 启动&&停⽌数据库字符集设置mysql配置⽂件/etc/f中加⼊default-character-set=utf8启动mysql服务: service mysqld start或者/etc/init.d/mysqld start开机启动:添加开机启动:chkconfig --add mysqld;开机启动:chkconfig mysqld on;查看开机启动设置是否成功chkconfig --list | grep mysql* mysqld 0:关闭 1:关闭 2:启⽤ 3:启⽤ 4:启⽤ 5:启⽤ 6:关闭停⽌:停⽌service mysqld stop4. 登陆等权限设置登录mysql数据库:mysq -u root password 123456⾸次使⽤创建root管理员和密码(mysql -u root -p输⼊密码即可?)mysql -u root;use mysql ;update user set password=password("123456") where user="root";flush privileges;忘记密码service mysqld stop;mysqld_safe --user=root --skip-grant-tables;这⼀步骤执⾏的时候不会出现新的命令⾏,你需要重新打开⼀个窗⼝执⾏下⾯的命令mysql -u root;use mysql ;update user set password=password("123456") where user="root";flush privileges;如果需要外⽹可以访问需要再做如下设置授权⽤户可以从远程登陆grant all PRIVILEGES on *.* to root@'%' identified by '123456';flush privileges ;5. 远程访问开放防⽕墙的端⼝号mysql增加权限:mysql库中的user表新增⼀条记录Host为“%”,User为“root”。

Linuxcentos7环境下MySQL安装教程

Linuxcentos7环境下MySQL安装教程

Linux centos7环境下MySQL安装教程MySQL所使用的SQL 语言是用于访问数据库的最常用标准化语言。

那么你知道Linux centos7环境下MySQL安装教程么?接下来是小编为大家收集的Linux centos7环境下MySQL安装教程,欢迎大家阅读:Linux centos7环境下MySQL安装教程1)、my.ini 保存到/etc/my.ini2)、用户权限,单独用户执行一、查找以前是否安装有mysql,使用下面命令:rpm –qa | grep -i mysql如果显示有如下包则说明已安装mysqlmysql-4.1.12-3.RHEL4.1mysqlclient10-3.23.58-4.RHEL4.1二、下载mysql解压包mysql-5.7.17-linux-glibc2.5-x86_64.tar (去网站上下载)网址:/mysql/MySQL-5.7/也可以在Linux操作系统底下进行下载,输入如下命令wget /mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz创建目录software用于存放我们待会要下载的mysql包,先去到该目录输入命令:cd /software下载完成后,你会在software目录下看到多出一份mysql安装包文件三、建立用户,以及mysql的目录1、groupadd mysql #建立一个mysql的组2、useradd -r -g mysqlmysql #建立mysql用户,并且把用户放到mysql组3、passwd mysql #给mysql用户设置一个密码四、解压mysql安装包1、先把tar.gz包移动到/usr/local 目录下,输入命令mv /software/MySQL/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz/usr/local2、解压tar.gz包先去到/usr/local 目录下,输入命令cd /usr/local解压命令 tarzxvfmysql-5.7.17-linux-glibc2.5-x86_64.tar.gz输入查看目录命令 ll会发现多出目录 mysql-5.7.17-linux-glibc2.5-x86_64注意:没有data 目录,my.ini文件在support-files 目录下3、改一下目录名字为 /usr/local/mysql(这是linux下mysql的默认安装安装目录)把解压出来的文件改下名字,改为mysql输入命令: mv mysql-5.7.17-linux-glibc2.5-x86_64 mysql五、配置相关的启动配置文件首先要去到support-files/文件目录下输入命令: cd support-files/1、复制f 到 /etc/f (mysql启动时自动读取)输入命令 f /etc/f2、解决乱码问题输入命令:vi /etc/f (进入可编辑状态)更改:[mysql]default-character-set=utf8(表示解决客户端乱码问题)[mysqld]default-storage-engine=INNODBcharacter_set_server=utf8(表示解决服务端乱码问题)3、复制mysql.server 到/etc/init.d/ 目录下【目的想实现mysqld -install这样开机自动执行效果】输入命令 cp mysql.server /etc/init.d/mysql (mysql是服务名)注意:/etc/init.d/ 目录,等效于注册表HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\services记录有那些服务4、修改/etc/init.d/mysql 参数输入命令 vi /etc/init.d/mysql给与两个目录位置basedir=/usr/local/mysqldatadir=/usr/local/mysql/data5、给目录/usr/local/mysql 更改拥有者输入命令 chown -R mysql:mysql /usr/local/mysql/六、初始化mysql的数据库1、初始化mysqlmysql_install_db (老版本的做法)新版本:初始化输入命令./mysqld --initialize --user=mysql--basedir=/usr/local/mysql --datadir=/usr/local/mysql/data 生成出一个data目录,代表数据库已经初始化成功并且mysql的root用户生成一个临时密码:(记录下临时密码XXX)2、给数据库加密输入命令./mysql_ssl_rsa_setup --datadir=/usr/local/mysql/data3、启动mysql输入命令 ./mysqld_safe --user=mysql & (&符表示提交到后台运行mysql服务)七、进入客户端1、登录输入命令 ./mysql -uroot -p然后再输入你的临时密码2、修改密码输入命令set password=password(‘xxxx')八、window远程访问Linux虚拟机的mysql先来看看数据库结构1、关闭防火墙 (或者给防火墙开放端口),这样window才能连接上输入命令 systemctl stop firewalld.service2、给Windows授权输入命令mysql>grant all privileges on *.* toroot@'%' identified by '123456';mysql>use mysql;mysql>select host,user from user;【多出一条远程登录用户记录】mysql>flush privileges;3、远程链接数据库,或者重启(init 6)。

CentOS7版本安装Mysql8.0.20版本数据库的详细教程

CentOS7版本安装Mysql8.0.20版本数据库的详细教程

CentOS7版本安装Mysql8.0.20版本数据库的详细教程相关阅读:CentOS7安装Mysql8.0.20步骤:官⽹下载有时速度⽐较慢,直接点击链接也可以下载:官⽹下载8.0.20Mysql包(bundle版本)1.创建mysql⽂件夹:[root@localhost ~]# mkdir /usr/local/mysql[root@localhost ~]# cd /usr/local/mysql/将下载的mysql包放在创建的MySQL⽂件夹内:[root@localhost mysql]# ll总⽤量 815000-rw-r--r--. 1 root root 834560000 5⽉ 13 10:44 mysql-8.0.20-1.el7.x86_64.rpm-bundle.tarmysql的安装版MD5码查看是否和官⽹上的相对应:[root@localhost mysql]# md5sum mysql-8.0.20-1.el7.x86_64.rpm-bundle.tarc8d062c1f74d9aab7dbdd5300b202b6e mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar将mysql的包解压得到⼏个内安装包:[root@localhost mysql]# tar -xvf mysql-8.0.20-1.el7.x86_64.rpm-bundle.tarmysql-community-libs-8.0.20-1.el7.x86_64.rpmmysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpmmysql-community-test-8.0.20-1.el7.x86_64.rpmmysql-community-common-8.0.20-1.el7.x86_64.rpmmysql-community-devel-8.0.20-1.el7.x86_64.rpmmysql-community-client-8.0.20-1.el7.x86_64.rpmmysql-community-libs-compat-8.0.20-1.el7.x86_64.rpmmysql-community-server-8.0.20-1.el7.x86_64.rpm[root@localhost mysql]# ll总⽤量 1630004-rw-r--r--. 1 root root 834560000 5⽉ 13 10:44 mysql-8.0.20-1.el7.x86_64.rpm-bundle.tar-rw-r--r--. 1 7155 31415 48822048 3⽉ 27 20:14 mysql-community-client-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 623508 3⽉ 27 20:14 mysql-community-common-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 8129988 3⽉ 27 20:14 mysql-community-devel-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 23599996 3⽉ 27 20:14 mysql-community-embedded-compat-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 4667884 3⽉ 27 20:14 mysql-community-libs-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 1277128 3⽉ 27 20:14 mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 512057468 3⽉ 27 20:15 mysql-community-server-8.0.20-1.el7.x86_64.rpm-rw-r--r--. 1 7155 31415 235369940 3⽉ 27 20:16 mysql-community-test-8.0.20-1.el7.x86_64.rpm依次安装顺序时common,libs,libs-compat,client,server:警告:mysql-community-common-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY准备中... ################################# [100%]正在升级/安装...1:mysql-community-common-8.0.20-1.e################################# [100%]警告:mysql-community-libs-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY准备中... ################################# [100%]正在升级/安装...1:mysql-community-libs-8.0.20-1.el7################################# [100%]警告:mysql-community-libs-compat-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY准备中... ################################# [100%]正在升级/安装...1:mysql-community-libs-compat-8.0.2################################# [100%]警告:mysql-community-client-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY准备中... ################################# [100%]正在升级/安装...1:mysql-community-client-8.0.20-1.e################################# [100%]警告:mysql-community-server-8.0.20-1.el7.x86_64.rpm: 头V3 DSA/SHA1 Signature, 密钥 ID ********: NOKEY准备中... ################################# [100%]正在升级/安装...1:mysql-community-server-8.0.20-1.e################################# [100%]编辑⼀下/etc/f⽂件:在最下⾯增加⼀⾏:lower_case_table_names=1initialize初始化:[root@localhost mysql]# mysqld --initialize[root@localhost mysql]#更改⼀下权限:[root@localhost mysql]# chown -R mysql:mysql /var/lib/mysql[root@localhost mysql]# ll /var/lib/总⽤量 8drwxr-xr-x. 4 root root 32 5⽉ 13 10:07 AccountsServicedrwxr-xr-x. 2 root root 6 8⽉ 3 2017 alsadrwxr-xr-x. 2 root root 274 5⽉ 13 10:14 alternativesdrwx------. 3 root root 18 5⽉ 13 10:17 authconfigdrwxr-xr-x. 2 root root 6 8⽉ 3 2017 bluetoothdrwxr-xr-x. 2 chrony chrony 6 8⽉ 4 2017 chronydrwxr-xr-x. 3 root root 17 5⽉ 13 10:06 colordrwxr-xr-x. 4 colord colord 67 5⽉ 13 10:23 colorddrwxr-xr-x. 2 root root 6 11⽉ 7 2016 dbusdrwxr-xr-x. 2 root root 6 8⽉ 4 2017 dhclientdrwxr-xr-x. 2 root root 6 8⽉ 3 2017 dnsmasqdrwxr-xr-x. 3 root root 34 5⽉ 13 10:24 flatpakdrwxr-xr-x. 2 root root 6 6⽉ 24 2014 fprintdrwxr-xr-x. 2 root root 6 11⽉ 5 2016 gamesdrwxrwx--T. 5 gdm gdm 70 5⽉ 13 10:23 gdmdrwxr-xr-x. 2 geoclue geoclue 6 8⽉ 2 2017 geocluedrwxr-xr-x. 4 root root 55 5⽉ 13 02:22 gssproxydrwxr-xr-x. 2 root root 6 8⽉ 2 2017 hypervdrwxr-xr-x. 2 root root 6 8⽉ 5 2017 initramfsdrwxr-xr-x. 8 root root 90 5⽉ 13 10:07 iscsidrwxr-xr-x. 8 root root 93 5⽉ 13 10:08 libvirtdrwxr-xr-x. 2 root root 6 11⽉ 6 2016 lldpaddrwxr-xr-x. 2 root root 6 8⽉ 2 2017 logrotatedrwx------. 2 root root 6 5⽉ 13 10:06 machinesdrwxr-xr-x. 2 root root 37 5⽉ 13 02:22 miscdrwxr-x---. 2 root slocate 6 11⽉ 5 2016 mlocatedrwxr-x--x. 6 mysql mysql 4096 5⽉ 13 11:05 mysql启动mysql服务看⼀下服务状态,看Active这⼀⾏的状态:[root@localhost mysql]# systemctl start mysqld.service[root@localhost mysql]# systemctl status mysqld.service● mysqld.service - MySQL ServerLoaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)Active: active (running) since 三 2020-05-13 11:09:35 CST; 8s agoDocs: man:mysqld(8)/doc/refman/en/using-systemd.htmlProcess: 16795 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS) Main PID: 16829 (mysqld)Status: "Server is operational"CGroup: /system.slice/mysqld.service└─16829 /usr/sbin/mysqld5⽉ 13 11:09:24 localhost.localdomain systemd[1]: Starting MySQL Server...5⽉ 13 11:09:35 localhost.localdomain systemd[1]: Started MySQL Server.[root@localhost mysql]#查看数据库初始的密码:[root@localhost mysql]# cat /var/log/mysqld.log | grep password2020-05-13T03:05:16.041238Z 6 [Note] [MY-010454][Server] A temporary password is generated for root@localhost: n_t#tk.Z?7)f使⽤初始密码登陆数据库:后更改密码:[root@localhost mysql]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 8Server version: 8.0.20Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.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> ALTER user 'root'@'localhost' identified with mysql_native_password by '123456';Query OK, 0 rows affected (0.04 sec)mysql> exitBye[root@localhost mysql]# mysql -uroot -pEnter password:Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 9Server version: 8.0.20 MySQL Community Server - GPLCopyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.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> SELECT VERSION;ERROR 1054 (42S22): Unknown column 'VERSION' in 'field list'mysql> SELECT VERSION();+-----------+| VERSION() |+-----------+| 8.0.20 |+-----------+1 row in set (0.00 sec)mysql>到此可以正常登陆数据库了,可以⾃⾏查找开启远程⽅式。

CentOS7安装MySQL8(RPM+Tar)+首次配置

CentOS7安装MySQL8(RPM+Tar)+首次配置

CentOS7安装MySQL8(RPM+Tar)+⾸次配置CentOS 7安装 MySQL 8(RPM+Tar)+⾸次配置参考centos6.5 mysql安装+远程访问+备份恢复+基本操作+卸载CentOS服务器下对mysql的优化centos7安装Mysql8.0步骤CentOS7安装MySQL8.0图⽂教程使⽤RPM安装MySQLCent OS的yum 源中默认是没有MySQL的,所以我们需要先去官⽹下载MySQL的repo源并安装.。

下载MySQL软件包1 cd /home/wxd2 mkdir mysql3 cd mysql安装Yum repo⽂件并更新 Yum 缓存1 rpm -ivh mysql80-community-release-el8-1.noarch.rpm更新 Yum1 yum clean all2 yum makecache使⽤Yum安装MySQL1 yum -y install mysql-community-server使⽤Tar包安装MySQL之前安装过⼀次后卸载,结果⽆论如何都⽆法⽤RPM安装。

提⽰缺少依赖,下⽅则是在本地⽤tar包安装。

下载MySQL的Tar包并解压在usr/local下创建mysql⽂件夹,⽤于存放下载的tar包1 cd /usr/local2 mkdir mysql3 cd mysql下载Tar包解压Tar包1 tar -xvf mysql-8.0.18-1.el7.x86_64.rpm-bundle.tar安装MySQL1 rpm -ivh mysql-community-common-8.0.18-1.el7.x86_64.rpm2 rpm -ivh mysql-community-libs-8.0.18-1.el7.x86_64.rpm3 rpm -ivh mysql-community-client-8.0.18-1.el7.x86_64.rpm4 rpm -ivh mysql-community-server-8.0.18-1.el7.x86_64.rpm⾸次启动配置通过下列命令完成对MySQL数据库的初始化和相关配置1 mysqld --initialize2 chown mysql:mysql /var/lib/mysql -R3 systemctl start mysqld.service4 systemctl enable mysqld通过下列命令查看数据库密码1 cat /var/log/mysqld.log | grep password登录数据库1 mysql -u root -p修改数据库密码1 ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新的密码';2 EXIT #退出数据库3 mysql -u root -p #使⽤新密码登录数据库其他问题在安装MySQL前务必检查系统中是否存在mariadb,如果存在则将其卸载。

Centos7中mysql安装以及命令

Centos7中mysql安装以及命令

Centos7中mysql安装以及命令Centos7将默认数据库mysql替换成了Mariadb,⾸先要卸载默认数据库的[root@localhost ~]# rpm -qa|grep mariadbmariadb-libs-5.5.52-1.el7.x86_64[root@localhost ~]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64开始安装mysql5.72. 进⼊/usr/local/⽬录,并解压[root@localhost local]#tar -zxvf mysql-advanced-5.6.24-linux-glibc2.5-x86_64.tar.gz将解压好的⽂件夹重命名为mysql5.73、创建⼀个mysql⽤户组和mysql的⽤户名[root@localhost local]# groupadd mysql[root@localhost local]# useradd -g mysql mysql //将mysql⽤户添加到mysql的⽤户组中4. 进⼊mysql5.7⽬录,并创建两个⽬录[root@localhost mysql5.7]# mkdir data[root@localhost mysql5.7]# mdir logs创建⼀个配置⽂件 f[root@localhost mysql5.7]# vim f关于mysql的配置⽂件 f配置 , 以下先给⼀个例⼦:[client]port = 3306socket = /var/lib/mysql/mysql.sock[mysql]#这个配置段设置启动MySQL服务的条件;在这种情况下,no-auto-rehash确保这个服务启动得⽐较快。

no-auto-rehash[mysqld]user = mysqlport = 3306socket = /var/lib/mysql/mysql.sockbasedir = /usr/local/mysqldatadir = /data/mysql/data/open_files_limit = 10240back_log = 600#在MYSQL暂时停⽌响应新请求之前,短时间内的多少个请求可以被存在堆栈中。

Centos7下安装MySQL8.0.23的步骤(小白入门级别)

Centos7下安装MySQL8.0.23的步骤(小白入门级别)

Centos7下安装MySQL8.0.23的步骤(⼩⽩⼊门级别)⾸先简单介绍⼀下什么叫MySQL;数据库简⽽⾔之就是存储数据的仓库,为了⽅便数据的存储和管理,它将数据按照特定的规律存储在磁盘上。

是为了实现⼀定的⽬的,按照某种规则组织起来的数据的集合;MySQL是⼀种开放源代码的关系型数据库管理系统(RDBMS),使⽤最常⽤的数据库管理语⾔--结构化bai查询语⾔(SQL)进⾏数据库管理。

通过数据库管理系统,可以有效的组织和管理存储在数据库中的数据。

那么我们常见的数据库模型:1,关系型数据库 MySql Oracle SQL Server2,⾮关系型数据库 2,1⽂档存储数据库 MongDB 2,2键值存储数据库 Redis Memcached 2,3列存储数据库 HBase 2,4图形数据库 Neo4J关于数据库在公司⾯试的题⽬都有那些呢? 1,SQL语句操作数据库 2,SQL语句操作表结构 3,表和类之间的关系 字段和属性之间的关系表对应的是java中的类,⽤来存储数据库中取出的数据字段名(列)和类中的成员变量属性⼀致表中的⾏根据类创建的对象3,SQL语句的介绍: MySql不认识java,那么就需要交互,需⽤到数据库认识的语⾔ SQL语句是数据代码库⼀⼂环境虚拟机: centos7MYSQL:mysql-8.0.23-1.el7.x86_64.rpm-bundle①⾸先要去把MySQL安装包下好①⼂②⼂③⼂④⼂⑤⼂按照以上步骤就将mysqi压缩包下载到电脑上了⼆⼂下⾯打开虚拟机并且使⽤远程⼯具xshell连接&CRT连接。

我这⾥使⽤xshellxshell6下载包提取码: 9nqz虚拟机这⾥就不介绍了,⽹上有很多安装虚拟机的⽅法①⼂打开虚拟机然后就不⽤管了;②⼂直接打开xshell输⼊IP创建远程连接③⼂输⼊⽤户密码④⼂登录成功三⼂正菜开始通过rpm -qa | grep mariadb 命令查看mariadb 的安装包②⼂再通过命令 rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps 卸载mariadb③⼂再通过rpm -qa | grep mariadb查看mariadb④⼂通过cd /usr/local/ 命令进⼊根⽬录下的usr⽬录下的local⽬录,这个⽬录是放⼀些本地的共享资源的⑤⼂通过ll查看⼀下⽬录结构⑥⼂通过mkdir mysql 命令在当前⽬录下创建⼀个名为 mysql 的⽬录,并且ll查看⼀下新建的mysql⽬录⑦⼂通过cd mysql进⼊mysql⽬录,再 ll看⼀下⽬录结构⑧⼂然后通过 rz 命令上传之前下载的mysql数据包⑨⼂上传完成A⼂再通过 ll 查看当前⽬录结构 B⼂通过 tar -xvf mysql-8.0.11-1.el7.x86_64.rpm-bundle.tar 命令解压tar 包C⼂通过 clear 命令清⼀下屏D⼂通过rpm -ivh mysql-community-common-8.0.11-1.el7.x86_64.rpm --nodeps --force 命令安装commonE ⼂通过rpm -ivh mysql-community-libs-8.0.11-1.el7.x86_64.rpm --nodeps --force命令安装libsF⼂.通过rpm -ivh mysql-community-client-8.0.11-1.el7.x86_64.rpm --nodeps --force命令安装clientG⼂通过rpm -ivh mysql-community-server-8.0.11-1.el7.x86_64.rpm --nodeps --force命令安装serverH⼂通过rpm -qa | grep mysql 查看已安装的mysql资源I⼂输⼊以下命令mysqld --initialize 初始化chown mysql:mysql /var/lib/mysql -R 授权systemctl start mysqld 开启mysql服务systemctl status mysqld 查看mysql 状态J⼂通过cat /var/log/mysqld.log | grep password 查看root初始密码K⼂使⽤root⽤户登录mysql ,并修改root⽤户密码mysql -u root -p #回车之后输⼊前⾯的初始密码也就是上⾯查看的初始密码(填⾃⼰的密码)然后输⼊alter user "root"@"localhost" identified by "Aa123456"; #修改密码(Aa123456 为⾃⼰设的密码可随意变换)L⼂然后再exit退出验证⼀下密码M⼂通过以下命令,进⾏远程访问的授权create user 'root'@'%' identified with mysql_native_password by 'Aa23456';grant all privileges on *.* to 'root'@'%' with grant option;flush privileges; #⽴即⽣效N⼂通过ALTER USER 'root'@'localhost' IDENTIFIED BY 'root' PASSWORD EXPIRE NEVER; 命令修改加密规则,MySql8.0 版本和 5.0 的加密规则不⼀样,⽽现在的可视化⼯具只⽀持旧的加密⽅式。

linuxcentos7安装mysql8的教程

linuxcentos7安装mysql8的教程

linuxcentos7安装mysql8的教程⼀、RPM版安装查看是否有其他版本的数据库,若有,删除⼲净⾮root⽤户必须要有sudo权限1.下载mysql相关安装包2.其他依赖(可以先跳过该步,看后⾯安装mysql时缺少什么依赖就安装什么依赖)到该⽹址下去寻找gcc、gcc-c++、openssl、perl及其依赖包3.安装mysql(未报错则表⽰安装成功)4.⾃定义配置mysql(如果不想改变mysql的默认相关⽬录,跳⾄第6步)修改Mysql默认的配置⽂件内容sudo vi /etc/f删除所有内容,加⼊以下内容:[mysqld]user=mysqlport=3306datadir=/app/mysql/datasocket=/app/mysql/mysql.socklog-error=/app/mysql/log/mysqld.logpid-file=/app/mysql/mysqld.pid[client]socket=/app/mysql/mysql.sock5.创建配置⽂件中的相关⽬录并修改权限sudo mkdir /app/mysql/data /app/mysql/log -psudo chown mysql:mysql /app/mysql -R6.初始化mysql7.启动mysql若启动出错:a.请查看mysql相关⽬录的所属⽤户和所属组是否是mysqlb.请查看selinux是否关闭:执⾏sudo getenforce得到的结果若不是Permissive,执⾏命令:sudo setenforce 0c.查看端⼝是否被占⽤d.若还是⽆法启动:请查看mysql错误⽇志以及sudo systemctl status mysqld或者journalctl -xe8.登录mysql查看Mysql的初始密码(root@localhost:后⾯的就是初始密码)sudo cat /app/mysql/log |grep root@localhost (做过第4步使⽤该命令)sudo cat /var/log/mysqld.log|grep root@localhost (未做过第4步使⽤该命令)登录mysql,复制上⾯的密码mysql -p9.修改mysql密码(初次登录必须修改密码,否则⽆法使⽤mysql命令)alter user 'root'@'localhost' identified by '你的密码';⼆、源码版安装⾮root⽤户必须要有sudo权限1.下载相关源码包2.安装低版本的gcc、gcc-c++(必须要做,否则升级gcc安装m4/gmp/mpfr/mpc时configure会报错:configure: error: no acceptable C compiler found in $PATH)3.安装源码版cmake必须安装openssl和openssl-devel依赖,下载⽹址同上,否则bootstrap会报错:找不到openssl(能连外⽹的可以直接使⽤命令:sudo yum -y install openssl openssl-devel)tar cmake-3.16.1.tgzcd cmake-3.16.1sudo ./bootstrapsudo makesudo make checksudo make install4.升级gcc、gcc-c++a.安装m4tar -xzvf m4-latest.tar.gzcd m4-1.4.17/sudo ./configure --prefix=/usr/local(--prefix指定安装路径)sudo make (编译)sudo make check (检查编译是否有错,注意是否有Error,可以不做)sudo make install (安装)m4 --version (查看m4版本)正确安装后可以看到如下结果b.安装gmpsudo ln -s /usr/local/bin/m4 /usr/bin (把m4做⼀个软连接到此路径下,否则configure时会报错:checking for suitable m4... configure: error: No usable m4 in $PATH or /usr/5bin (see config.log for reasons).)tar -xvf gmp-6.2.0.tar.xzcd gmp-6.2.0sudo ./configure --prefix=/usr/local/gmp-6.2 (⾮管理员必须要sudo,否则会报错:Permission denied)sudo makesudo make checksudo make installc.安装mpfrtar -xzvf mpfr-4.0.2.tar.gzcd mpfr-4.0.2sudo ./configure --prefix=/usr/local/mpfr-4.0 --with-gmp=/usr/local/gmp-6.2 (--with-gmp为gmp的安装⽬录)sudo makesudo make checksudo make installd.安装mpctar -xzvf mpc-1.1.0.tar.gzcd mpc-1.1sudo ./configure --prefix=/usr/local/mpc-1.1 --with-gmp=/usr/local/gmp-6.2 --with-mpfr=/usr/local/mpfr-4.0sudo makesduo make checksudo make installe.加⼊库⽂件(/usr/local/mpfr-4.0/lib/必须加⼊库⽂件,其他两个可以不做,否则安装升级gcc编译时会报错:error while loading shared libraries: libmpfr.so.6: cannot open shared object file: No such file or directory)sudo vi /etc/ld.so.conf/usr/local/mpfr-4.0/lib//usr/local/gmp-6.2/lib/usr/local/mpc-1.1/libsudo ldconfig (使上⾯的操作⽣效)或者做软连接sudo ln -s /usr/local/mpfr-4.0/lib/libmpfr.so.6 /usr/bin或者复制sudo cp /usr/local/mpfr-4.0/lib/libmpfr.so.6 /usr/bin/f.安装其他依赖(系统未安装依赖包时,必须要装,否则升级gcc编译时会报错:mpc.h:没有那个⽂件或⽬录)下载gmp-devel和libmpc-devel及其依赖包(能连外⽹的可以直接使⽤命令:sudo yum -y install gmp-devel libmpc-devel)g.升级gcctar -xzvf gcc-9.2.0.tar.gzcd gcc-9.2.0sudo ./configure --prefix=/usr/local/gcc-9.2 \--enable-bootstrap\--enable-checking=release \--enable-languages=c,c++ \--enable-threads=posix \--disable-checking\--disable-multilib\--enable--long-long\--with-gmp=/usr/local/gmp-6.2\--with-mpfr=/usr/local/mpfr-4.0\--with-mpc=/usr/local/mpc-1.1sudo make (编译时间较长,1个⼩时的样⼦)sudo make checksudo make install务必卸载低版本的gcc、gcc-c++sudo rpm -e gcc-c++sudo rpm -e gccsudo vi /etc/profile export PATH=$PATH:/usr/local/gcc/bin source /etc/profile查看gcc版本号gcc --version5.安装源码版mysql安装ncurses-devel依赖,否则cmake报错:Curses library not found.Please install appropriate package(能连外⽹的可以直接使⽤命令:sudo yum -y install ncurses-devel,不能连上外⽹的下载地址同第2步⼀样) tar -xzvf mysql-8.0.19.tar.gzcd mysql-8.0.19cmake . -DCMAKE_INSTALL_PREFIX=/app/mysql\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DENABLED_LOCAL_INFILE=ON\-DWITH_SSL=system\-DMYSQL_DATADIR=/app/mysql/data\-DSYSCONFDIR=/app/mysql/config\-DMYSQL_TCP_PORT=3306\-DMYSQL_UNIX_ADDR=/app/mysql/mysql.sock\-DWITH_BOOST=/home/mcbadm/mysql8/\-DFORCE_INSOURCE_BUILD=1-DDEFAULT_CHARSET:设置字符集-DDEFAULT_COLLATION:设置排序规则-DENABLED_LOCAL_INFILE=ON:启⽤本地数据导⼊⽀持-DWITH_SSL=system:启⽤ssl库⽀持-DMYSQL_DATADIR:数据⽂件⽬录,可任意-DSYSCONFDIR:配置⽂件⽬录,可任意-DMYSQL_TCP_PORT:mysql监听的TCP端⼝-DMYSQL_UNIX_ADDR:mysql.sock路径,可任意-DWITH_BOOST:boost源码包所在⽬录-DFORCE_INSOURCE_BUILD:强制建⽴未存在的资源⽬录cmake若报错,请找到原因解决后删除CMakeCache.txt再次cmakesudo rm -rf /usr/lib64/libstdc++.so.6* (删掉所有低版本c++的库⽂件)sudo ln -s /usr/local/gcc-9.2/lib64 /usr/lib64 (把新安装的⾼本版c++库⽂件加⼊到系统库⽂件中)sudo make (需要⼤概1⼩时)sudo make install6.编写配置⽂件,建⽴⽬录并授权sudo mkdir /app/mysql/configsudo cd /app/mysqlsudo vi config/f加⼊以下内容:[mysqld]user=mysqlport=3306datadir=/app/mysql/datasocket=/app/mysql/mysql.sock[mysqld_safe]log-error=/app/mysql/logs/mysql-err.logpid-file=/app/mysql/mysql.pid[client]socket=/app/mysql/mysql.socksudo useradd mysql -s /sbin/nologinsudo mkdir -p /app/mysql/logssudo touch /app/mysql/logs/mysql-err.logsudo chown -R mysql.mysql /app/mysql7.初始化并登陆修改密码初始化sudo /app/mysql/bin/mysqld --initialize-insecure --user=mysql --datadir=/app/mysql/data --basedir=/app/mysql (⽆初始密码的,若想要初始密码,使⽤--initialize)启动sudo /app/mysql/support-files/mysql.server start登陆(若⽆初始密码直接回车即可)sudo /app/mysql/bin/mysql -p修改密码alter user 'root'@'localhost' identified by '密码';总结以上所述是⼩编给⼤家介绍的linux centos7安装mysql8的教程,希望对⼤家有所帮助!。

centos7通过yum安装mysql的方法

centos7通过yum安装mysql的方法

centos7通过yum安装mysql的⽅法1.检查mysql是否安装yum list installed | grep mysql如果有的话就全部卸载yum -y remove +数据库名称2.MySQL 依赖 libaio,所以先要安装 libaioyum search libaio # 检索相关信息yum install libaio # 安装依赖包3.下载 MySQL Yum Repository如果找不到wget命令则先yum install wgetwget /get/mysql-community-release-el7-5.noarch.rpm4.添加 MySQL Yum Repository添加 MySQL Yum Repository 到你的系统 repository 列表中,执⾏yum localinstall mysql-community-release-el7-5.noarch.rpm5.验证下是否添加成功yum repolist enabled | grep "mysql.*-community.*"6.选择要启⽤ MySQL 版本查看 MySQL 版本,执⾏yum repolist all | grep mysql可以看到 5.5, 5.7 版本是默认禁⽤的,因为现在最新的稳定版是 5.6yum repolist enabled | grep mysql查看当前的启动的 MySQL 版本7.通过 Yum 来安装 MySQLyum install mysql-community-serverYum 会⾃动处理 MySQL 与其他组件的依赖关系此时MySQL 安装完成,它包含了 mysql-community-server、mysql-community-client、mysql-community-common、mysql-community-libs 四个包。

centos8安装mysql8.0.22

centos8安装mysql8.0.22

centos8安装mysql8.0.22 1,输⼊:2、安装数据源然后输⼊:yum install mysql80-community-release-el8-1.noarch.rpm3、检查数据源查看mysql源是否安装成功:yum repolist enabled | grep "mysql.*-community.*"4、配置数据源(可不配置)修改yum源,可不配置配置yum源:cat /etc/yum.repos.d/mysql-community.repo5、禁⽤CentOS8⾃带mysql模块禁⽤CentOS8⾃带的mysql模块yum module disable mysql6、安装数据库真正安装mysql安装语句:yum install mysql-community-serveryum install mysql-community-serverIs this ok [y/Y] ⼀路 y到底7、启动mysql输⼊:service mysqld startservice mysqld status8、显⽰mysql的随机密码输⼊:grep 'temporary password' /var/log/mysqld.loggrep 'temporary password' /var/log/mysqld.log9、登录并修改mysql密码登录:mysql -u root -p然后输⼊上⾯⽣成的密码修改密码:ALTER USER 'root'@'localhost' IDENTIFIED BY 'Root_21root';查看密码策略:SHOW VARIABLES LIKE 'validate_password%';修改密码长度:set global validate_password.length=1;(长度)修改密码等级:set global validate_password.policy=0;(等级)修改后再次查看设置⾃⼰想要的密码ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';Mysql8.0.22开放远程访问真确写法:1、先创建权限记录:create user 'root'@'%' identified by 'root123';2、授权:grant all privileges on *.* to 'root'@'%' with grant option;两句话分开写:开放防⽕墙端⼝sqlyog连接的坑本地去连接mysql时报错,错误 2058 Plugin caching_sha2_password could not be loaded由于mysql8.0的加密⽅法变了。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
相关文档
最新文档