Centos+安装MySQL全过程

合集下载

CentOS7安装MySQL8详细步骤

CentOS7安装MySQL8详细步骤

CentOS7安装MySQL8详细步骤CentOS7安装MySQL8详细步骤⼀,官⽹下载⼆,装卸 mariadb1,查看 mariadb 的安装包rpm -qa | grep mariadb2,装卸 mariadbrpm -e mariadb-libs-5.5.60-1.el7_5.x86_64 --nodeps3,再次查看 mariadbrpm -qa | grep mariadb三,在/usr/local下创建mysql⽂件夹mkdir mysql四,把下载的安装包放⼊mysql⽬录五,解压 tar 包tar -xvf mysql-8.0.17-1.el7.x86_64.rpm-bundle.tar六,安装 commonrpm -ivh mysql-community-common-8.0.17-1.el7.x86_64.rpm --nodeps --force注:a,--nodeps rpm在安装/卸载时,不检查依赖关系,例如安装/卸载B,B依赖C导致⽆法安装/卸载,使⽤--nodeps就可以安装/卸载成功b,--force 强制安装/卸载七,安装 libsrpm -ivh mysql-community-libs-8.0.17-1.el7.x86_64.rpm --nodeps --force⼋,安装 clientrpm -ivh mysql-community-client-8.0.17-1.el7.x86_64.rpm --nodeps --force九,安装 serverrpm -ivh mysql-community-server-8.0.17-1.el7.x86_64.rpm --nodeps --force⼗,检查确认rpm -qa | grep mysql⼗⼀,对mysql数据库进⾏初始化和相关配置1,mysqld --initialize;如果报错是因为没有安装所需要的依赖包执⾏:yum install -y libaio2,设置⽂件拥⽤者chown mysql:mysql /var/lib/mysql -R;3,systemctl start mysqld.service;4,systemctl enable mysqld;设置开机⾃启⼗⼆,修改root初始密码,并修改加密规则,MySql8.0 版本和 5.0 的加密规则不⼀样,⽽现在的可视化⼯具只⽀持旧的加密⽅式1,查看root的初始密码:cat /var/log/mysqld.log | grep password初始密码为:q-dqgt:xM5f82,进⼊数据库登陆界⾯:mysql -uroot -p输⼊之前查询的密码,注意不会显⽰3,修改root密码,并修改加密规则ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '新密码';4,通过 exit; 命令退出 MySQL,然后通过新密码再次登陆⼗三,进⾏远程访问的授权(登录MySQL后操作)1,use mysql;2,select host from user where user='root';3,update user set host='%' where user='root';4,flush privileges;⼗四,设置密码永不过期1,ALTER USER 'root'@'%' IDENTIFIED BY '新密码' PASSWORD EXPIRE NEVER;2,flush privileges;。

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离线安装包的⽅式都可以。

centos6.6下安装mysql5.1.73

centos6.6下安装mysql5.1.73

Centos下安装mysql5.1.73一、卸载掉原有mysql[root@xiaoluo ~]# rpm -qa | grepmysql// 这个命令就会查看该操作系统上是否已经安装了mysql数据库有的话,我们就通过 rpm -e 命令或者 rpm -e --nodeps命令来卸载掉[root@xiaoluo ~]# rpm -e mysql// 普通删除模式[root@xiaoluo ~]# rpm -e --nodepsmysql// 强力删除模式,如果使用上面命令删除时,提示有依赖的其它文件,则用该命令可以对其进行强力删除在删除完以后我们可以通过 rpm -qa | grepmysql命令来查看mysql是否已经卸载成功!!二、通过yum来进行mysql的安装我是通过yum的方式来进行mysql的数据库安装,首先我们可以输入 yum list | grep mysql命令来查看yum上提供的mysql数据库可下载的版本:[root@xiaoluo ~]#yum list | grepmysql然后我们可以通过输入 yum install -y mysql-servermysqlmysql-devel命令将mysq lmysql-server mysql-devel都安装好(注意:安装mysql时我们并不是安装了mysql客户端就相当于安装好了mysql数据库了,我们还需要安装mysql-server服务端才行)[root@xiaoluo ~]# yum install -y mysql-server mysqlmysql-devel我们可以通过如下命令,查看刚安装好的mysql-server的版本[root@xiaoluo ~]#rpm -qi mysql-server我们在安装完mysql数据库以后,会发现会多出一个mysqld的服务,这个就是咱们的数据库服务,我们通过输入service mysqld start命令就可以启动我们的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。

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的教程,希望对⼤家有所帮助,如果⼤家有任何疑问请给我留⾔,⼩编会及时回复⼤家的。

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安装Mysql并设置开机自启动

CentOS7安装Mysql并设置开机自启动

CentOS7安装Mysql并设置开机⾃启动CentOS 7不带Mysql数据库了,默认的数据库是MariaDB(Mysql的⼀个分⽀)。

可以按照以下步骤⼿动安装Mysql数据库。

0. 看起来mysql⼜提供yum安装了。

yum install mysql-server后⾯的没时间可以不看了。

1. 下载rpm安装⽂件2. 执⾏rpm安装rpm -ivh mysql-community-release-el7.rpm依赖解析完成后,出现下列选项:1 Dependencies Resolved23 ================================================================================================================================================================4 Package Arch Version Repository Size5 ================================================================================================================================================================6 Installing:7 mysql-community-libs x86_64 5.6.32-2.el7 mysql56-community 2.0 M8 replacing mariadb-libs.x86_64 1:5.5.47-1.el7_29 mysql-community-server x86_64 5.6.32-2.el7 mysql56-community 59 M10 Installing for dependencies:11 mysql-community-client x86_64 5.6.32-2.el7 mysql56-community 19 M12 mysql-community-common x86_64 5.6.32-2.el7 mysql56-community 256 k13 perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base32 k14 perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base57 k15 perl-DBI x86_64 1.627-4.el7 base802 k16 perl-IO-Compress noarch 2.061-2.el7 base260 k17 perl-Net-Daemon noarch 0.48-5.el7 base51 k18 perl-PlRPC noarch 0.2020-14.el7 base36 k1920 Transaction Summary21 ================================================================================================================================================================22 Install 2 Packages (+8 Dependent packages)2324 Total download size: 82 M25 Is this ok [y/d/N]:3. 可以看出,server和client都被选择安装。

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 四个包。

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可以简单修改配置如下。

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>到此可以正常登陆数据库了,可以⾃⾏查找开启远程⽅式。

CentosMySQL5.7安装、升级教程

CentosMySQL5.7安装、升级教程

CentosMySQL5.7安装、升级教程MySQL 5.7安装、升级笔记分享:卸载当前的 MySQL查看当前 MySQL 版本:[root@coderknock ~]# mysql -Vmysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (i386) using readline 5.1停⽌ MySQL 服务[root@coderknock ~]# service mysqld stopStopping mysqld: [ OK ]备份数据【数据不重要可以忽略】备份数据库,升级MySQL通常不会丢失数据,但保险起见,我们需要做这⼀步。

输⼊命令:[root@coderknock ~]# mysqldump -u xxx -h xxx -P 3306 -p --all-databases > databases.sql卸载旧版本 MySQL[root@coderknock ~]# yum remove mysql mysql-*Loaded plugins: securitySetting up Remove ProcessResolving Dependencies--> Running transaction check---> Package mysql.i686 0:5.1.73-7.el6 will be erased---> Package mysql-libs.i686 0:5.1.73-7.el6 will be erased--> Processing Dependency: libmysqlclient.so.16 for package: 2:postfix-2.6.6-6.el6_7.1.i686--> Processing Dependency: libmysqlclient.so.16 for package: perl-DBD-MySQL-4.013-3.el6.i686--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: 2:postfix-2.6.6-6.el6_7.1.i686--> Processing Dependency: libmysqlclient.so.16(libmysqlclient_16) for package: perl-DBD-MySQL-4.013-3.el6.i686--> Processing Dependency: mysql-libs for package: 2:postfix-2.6.6-6.el6_7.1.i686---> Package mysql-server.i686 0:5.1.73-7.el6 will be erased--> Running transaction check---> Package perl-DBD-MySQL.i686 0:4.013-3.el6 will be erased---> Package postfix.i686 2:2.6.6-6.el6_7.1 will be erased--> Processing Dependency: /usr/sbin/sendmail for package: cronie-1.4.4-16.el6_8.2.i686--> Processing Dependency: /usr/sbin/sendmail for package: redhat-lsb-core-4.0-7.el6.centos.i686--> Running transaction check---> Package cronie.i686 0:1.4.4-16.el6_8.2 will be erased--> Processing Dependency: cronie = 1.4.4-16.el6_8.2 for package: cronie-anacron-1.4.4-16.el6_8.2.i686---> Package redhat-lsb-core.i686 0:4.0-7.el6.centos will be erased--> Running transaction check---> Package cronie-anacron.i686 0:1.4.4-16.el6_8.2 will be erased--> Processing Dependency: /etc/cron.d for package: crontabs-1.10-33.el6.noarch--> Processing Dependency: /etc/cron.d for package: sysstat-9.0.4-31.el6.i686--> Restarting Dependency Resolution with new changes.--> Running transaction check---> Package crontabs.noarch 0:1.10-33.el6 will be erased---> Package sysstat.i686 0:9.0.4-31.el6 will be erased--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================================================ Removing:mysql i686 5.1.73-7.el6 @base 2.3 Mmysql-libs i686 5.1.73-7.el6 @base 3.9 Mmysql-server i686 5.1.73-7.el6 @base 24 MRemoving for dependencies:cronie i686 1.4.4-16.el6_8.2 @updates 169 kcronie-anacron i686 1.4.4-16.el6_8.2 @updates 38 kcrontabs noarch 1.10-33.el6 @anaconda-CentOS-201311291201.i386/6.5 2.4 kperl-DBD-MySQL i686 4.013-3.el6 @base 341 kpostfix i686 2:2.6.6-6.el6_7.1 @base 9.3 Mredhat-lsb-core i686 4.0-7.el6.centos @anaconda-CentOS-201311291201.i386/6.5 22 ksysstat i686 9.0.4-31.el6 @base 804 kTransaction Summary============================================================================================================================================================================================ Remove 10 Package(s)Installed size: 41 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionErasing : mysql-server-5.1.73-7.el6.i686 1/10warning: /var/log/mysqld.log saved as /var/log/mysqld.log.rpmsaveErasing : redhat-lsb-core-4.0-7.el6.centos.i686 2/10/var/tmp/rpm-tmp.Y5QGjy: line 1: lsb_release: command not foundErasing : mysql-5.1.73-7.el6.i686 3/10Erasing : perl-DBD-MySQL-4.013-3.el6.i686 4/10Erasing : sysstat-9.0.4-31.el6.i686 5/10Erasing : crontabs-1.10-33.el6.noarch 6/10Erasing : cronie-anacron-1.4.4-16.el6_8.2.i686 7/10Erasing : cronie-1.4.4-16.el6_8.2.i686 8/10Erasing : 2:postfix-2.6.6-6.el6_7.1.i686 9/10Erasing : mysql-libs-5.1.73-7.el6.i686 10/10Verifying : redhat-lsb-core-4.0-7.el6.centos.i686 1/10Verifying : perl-DBD-MySQL-4.013-3.el6.i686 2/10Verifying : mysql-server-5.1.73-7.el6.i686 3/10Verifying : crontabs-1.10-33.el6.noarch 4/10Verifying : sysstat-9.0.4-31.el6.i686 5/10Verifying : cronie-anacron-1.4.4-16.el6_8.2.i686 6/10Verifying : cronie-1.4.4-16.el6_8.2.i686 7/10Verifying : mysql-libs-5.1.73-7.el6.i686 8/10Verifying : mysql-5.1.73-7.el6.i686 9/10Verifying : 2:postfix-2.6.6-6.el6_7.1.i686 10/10Removed:mysql.i686 0:5.1.73-7.el6 mysql-libs.i686 0:5.1.73-7.el6 mysql-server.i686 0:5.1.73-7.el6Dependency Removed:cronie.i686 0:1.4.4-16.el6_8.2 cronie-anacron.i686 0:1.4.4-16.el6_8.2 crontabs.noarch 0:1.10-33.el6 perl-DBD-MySQL.i686 0:4.013-3.el6 postfix.i686 2:2.6.6-6.el6_7.1redhat-lsb-core.i686 0:4.0-7.el6.centos sysstat.i686 0:9.0.4-31.el6Complete!这样就卸载完成了,为了保险起见我们检查⼀下系统中是否还有 MySQL 相关内容没有删除⼲净[root@coderknock ~]# yum list installed | grep mysql[root@coderknock ~]#上⾯的情况是没有未删除部分,如果有的话可通过下⾯的命令删除:[root@coderknock ~]# yum remove mysql-libs下载最新版本的 MySQL查看系统配置信息选择对应 MySQL 包[root@coderknock ~]# uname -r3.10.104-1.el6.elrepo.i686在浏览器打开 sohu提供的然后根据⾃⼰系统配置选择对应的 rpm 包,右键复制⽂件链接,我的选择如下:下载并解压[root@coderknock ~]# wget /mysql/MySQL-5.7/mysql-5.7.17-1.el6.i686.rpm-bundle.tar--2017-01-06 22:46:15-- /mysql/MySQL-5.7/mysql-5.7.17-1.el6.i686.rpm-bundle.tarResolving ... 119.188.36.70Connecting to |119.188.36.70|:80... connected.HTTP request sent, awaiting response... 200 OKLength: 448163840 (427M) [application/octet-stream]Saving to: “mysql-5.7.17-1.el6.i686.rpm-bundle.tar”100%[=============================================================================================================================================================>] 448,163,840 9.98M/s in 45s 2017-01-06 22:47:00 (9.54 MB/s) - “mysql-5.7.17-1.el6.i686.rpm-bundle.tar” saved [448163840/448163840][root@coderknock ~]# tar xvf mysql-5.7.17-1.el6.i686.rpm-bundle.tarmysql-community-libs-compat-5.7.17-1.el6.i686.rpmmysql-community-client-5.7.17-1.el6.i686.rpmmysql-community-embedded-devel-5.7.17-1.el6.i686.rpmmysql-community-devel-5.7.17-1.el6.i686.rpmmysql-community-common-5.7.17-1.el6.i686.rpmmysql-community-test-5.7.17-1.el6.i686.rpmmysql-community-embedded-5.7.17-1.el6.i686.rpmmysql-community-libs-5.7.17-1.el6.i686.rpmmysql-community-server-5.7.17-1.el6.i686.rpm安装及配置安装 rpm 【有依赖关系,请按下⾯的步骤安装,搜索 [root@coderknock ~]# 可跳过安装⽇志直接查看相关命令】[root@coderknock ~]# yum localinstall mysql-community-common-5.7.17-1.el6.i686.rpmLoaded plugins: securitySetting up Local Package ProcessExamining mysql-community-common-5.7.17-1.el6.i686.rpm: mysql-community-common-5.7.17-1.el6.i686Marking mysql-community-common-5.7.17-1.el6.i686.rpm to be installedResolving Dependencies--> Running transaction check---> Package mysql-community-common.i686 0:5.7.17-1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================================================ Installing:mysql-community-common i686 5.7.17-1.el6 /mysql-community-common-5.7.17-1.el6.i686 2.5 MTransaction Summary============================================================================================================================================================================================ Install 1 Package(s)Total size: 2.5 MInstalled size: 2.5 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : mysql-community-common-5.7.17-1.el6.i686 1/1Verifying : mysql-community-common-5.7.17-1.el6.i686 1/1Installed:mysql-community-common.i686 0:5.7.17-1.el6Complete![root@coderknock ~]# yum localinstall mysql-community-libs-5.7.17-1.el6.i686.rpmLoaded plugins: securitySetting up Local Package ProcessExamining mysql-community-libs-5.7.17-1.el6.i686.rpm: mysql-community-libs-5.7.17-1.el6.i686Marking mysql-community-libs-5.7.17-1.el6.i686.rpm to be installedResolving Dependencies--> Running transaction check---> Package mysql-community-libs.i686 0:5.7.17-1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================================================ Installing:mysql-community-libs i686 5.7.17-1.el6 /mysql-community-libs-5.7.17-1.el6.i686 7.8 MTransaction Summary============================================================================================================================================================================================ Install 1 Package(s)Total size: 7.8 MInstalled size: 7.8 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : mysql-community-libs-5.7.17-1.el6.i686 1/1Verifying : mysql-community-libs-5.7.17-1.el6.i686 1/1Installed:mysql-community-libs.i686 0:5.7.17-1.el6Complete![root@coderknock ~]# yum localinstall mysql-community-client-5.7.17-1.el6.i686.rpmLoaded plugins: securitySetting up Local Package ProcessExamining mysql-community-client-5.7.17-1.el6.i686.rpm: mysql-community-client-5.7.17-1.el6.i686Marking mysql-community-client-5.7.17-1.el6.i686.rpm to be installedResolving Dependencies--> Running transaction check---> Package mysql-community-client.i686 0:5.7.17-1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================================================ Installing:mysql-community-client i686 5.7.17-1.el6 /mysql-community-client-5.7.17-1.el6.i686 87 MTransaction Summary============================================================================================================================================================================================ Install 1 Package(s)Total size: 87 MInstalled size: 87 MIs this ok [y/N]: ^[[A^HyIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : mysql-community-client-5.7.17-1.el6.i686 1/1Verifying : mysql-community-client-5.7.17-1.el6.i686 1/1Installed:mysql-community-client.i686 0:5.7.17-1.el6Complete![root@coderknock ~]# yum localinstall mysql-community-server-5.7.17-1.el6.i686.rpmLoaded plugins: securitySetting up Local Package ProcessExamining mysql-community-server-5.7.17-1.el6.i686.rpm: mysql-community-server-5.7.17-1.el6.i686Marking mysql-community-server-5.7.17-1.el6.i686.rpm to be installedResolving Dependencies--> Running transaction check---> Package mysql-community-server.i686 0:5.7.17-1.el6 will be installed--> Finished Dependency ResolutionDependencies Resolved============================================================================================================================================================================================ Package Arch Version Repository Size============================================================================================================================================================================================ Installing:mysql-community-server i686 5.7.17-1.el6 /mysql-community-server-5.7.17-1.el6.i686 695 MTransaction Summary============================================================================================================================================================================================ Install 1 Package(s)Total size: 695 MInstalled size: 695 MIs this ok [y/N]: yDownloading Packages:Running rpm_check_debugRunning Transaction TestTransaction Test SucceededRunning TransactionInstalling : mysql-community-server-5.7.17-1.el6.i686 1/1Verifying : mysql-community-server-5.7.17-1.el6.i686 1/1Installed:mysql-community-server.i686 0:5.7.17-1.el6Complete!配置查看版本[root@coderknock ~]# mysql -Vmysql Ver 14.14 Distrib 5.7.17, for Linux (i686) using EditLine wrapper启动 MySQL[root@coderknock ~]# service mysqld startMySQL Daemon failed to start.Starting mysqld: [FAILED]上⾯的情况说明启动失败,这是因为经过上⾯的步骤,MySQL 最新版已经安装到我们的系统了,但这是还没有初始化数据,所以导致⽆法启动。

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暂时停⽌响应新请求之前,短时间内的多少个请求可以被存在堆栈中。

linux之centos7搭建mysql5.7.29的详细过程

linux之centos7搭建mysql5.7.29的详细过程

linux之centos7搭建mysql5.7.29的详细过程1.下载mysql  1.1下载地址  1.2版本选择2.管理组及⽬录权限  2.1解压mysql tar -zxf mysql-5.7.29-linux-glibc2.12-x86_64.tar.gz上传⽬录/home/tools 2.2重命名 mv mysql-5.7.29-linux-glibc2.12-x86_64 mysql-5.7.29 2.3移动指定⽬录 mv mysql-5.7.29 /usr/local/ 2.4添加⽤户组与⽤户 groupadd mysql useradd -r -g mysql mysql 2.5修改⽬录权限 chown -R mysql:mysql /usr/local/mysql-5.7.29/3.安装mysql  3.1配置mysql服务 cp /usr/local/mysql-5.7.29/support-files/mysql.server /etc/init.d/mysql 3.2修改mysql服务 vi /etc/init.d/mysql 3.3 修改配置⽂件f vi /etc/f 拷贝内容如下,按需调整参数[client]port = 33066default-character-set=utf8[mysqld]# ⼀般配置选项basedir = /usr/local/mysql-5.7.29datadir = /usr/local/mysql-5.7.29/dataport = 33066character-set-server=utf8default_storage_engine = InnoDBsql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZEO, NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION 3.4初始化mysql /usr/local/mysql-5.7.29/bin/mysqld --initialize--user=mysql --basedir=/usr/local/mysql-5.7.29 --datadir=/usr/local/mysql-5.7.29/data 成功如下,注意密码 3.5启动服务 service mysql start4.登录与远程设置 4.1登录mysql ./mysql -u root p 记住注册密码 4.2修改root登录密码 set password=password('新密码'); 4.3开启远程访问GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密码';flush privileges;5.环境变量与开机启动配置 5.1设置环境变量 vi /etc/profile 添加如下内容# mysql environmentexport MYSQL_HOME=/usr/local/mysqlexport PATH=$PATH:$MYSQL_HOME/bin source /etc/profile更新系统变量 5.2开机启动 chkconfig --add mysql mysql服务到⾃启服务 chkconfig mysql on 设置⾃启 chkconfig --list查看服务列表总结到此这篇关于linux 之centos7搭建mysql5.7.29的详细过程的⽂章就介绍到这了,更多相关centos7搭建mysql5.7.29内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。

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 的加密规则不⼀样,⽽现在的可视化⼯具只⽀持旧的加密⽅式。

CentOS7.5安装Mysql8.0.19的教程图文详解

CentOS7.5安装Mysql8.0.19的教程图文详解

CentOS7.5安装Mysql8.0.19的教程图⽂详解⼀、前⾔此篇⽂章安装mysql部分没有截图,适合有⼀定基础的同学。

安装⽅法是通过mysql官⽹下载的tar⽂件,解压后安装rpm⽂件。

因为公司⽹络慢,使⽤yum⽅法安装时,⽂件经常下载⼀半就不⾏了,所以使⽤这种⽅法。

只要tar⽂件在,拷到哪安装都可以(⽹速好的同学请忽略)。

⼆、安装⽂件下载页⾯拉到最后,点击红框链接:在打开的页⾯,点击红框链接:在打开的页⾯这样选择(CentOS 是基于红帽的,所以这样选择),然后下载:下载的mysql版本是:8.0.19三、CentOS7安装Mysql操作Linux版本CentOS7的版本是:7.5.1804清理⼯作1.通过rpm -qa | grep mariadb命令查看mariadb的安装包2.如果有信息,通过rpm -e --nodeps mariadb-libs-x.x.xx-x.xxx.x86_64命令卸载3.通过rpm -qa | grep mysql命令查看mysql的安装包4.如果有信息,通过yum remove mysql-community-***命令依次删除5.通过find / -name mysql命令查找mysql配置⽂件6.如果有信息,通过rm -rf ⽂件路径命令依次删除初始化⽬录1.进⼊虚拟机2.通过命mkdir /usr/local/mysql命令创建mysql⽂件夹3.上传上⾯下载的mysql安装⽂件到/usr/local/mysql⽬录有想法的同学可以放到其他⽬录开始安装程序1.通过tar -xvf mysql-8.0.19-1.el7.x86_64.rpm-bundle.tar命令解压 tar 包。

2.通过rpm -ivh --nodeps --force mysql-community-common-8.0.19-1.el7.x86_64.rpm命令安装 common。

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的教程,希望对⼤家有所帮助!。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
warning: MySQL-client-5.0.9-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
Preparing... ########################################### [100%]
usr/bin/mysqladmin -u root password 'new-password'
格式:mysqladmin -u用户名ห้องสมุดไป่ตู้-p旧密码 password 新密码
2、例子
例1:给root加个密码123456。
键入以下命令 :
[root@test1 local]# /usr/bin/mysqladmin -u root password 123456
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql>
出现了“mysql>”提示符,恭喜你,安装成功!
增加了密码后的登录格式如下:
mysql -u root -p
Enter password: (输入密码)
其中-u后跟的是用户名,-p要求输入密码,回车后在输入密码处输入密码。
注意:这个mysql文件在/usr/bin目录下,与后面讲的启动文件/etc/init.d/mysql不是一个文件。
四、MySQL的几个重要目录
MySQL安装完成后不象SQL Server默认安装在一个目录,它的数据库文件、配置文件和命令文件分别在不同的目录,了解这些目
[root@test1 local]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.16-standard
3、相关命令
/usr/bin(mysqladmin mysqldump等命令)
4、启动脚本
/etc/rc.d/init.d/(启动脚本文件mysql的目录)
五、修改登录密码
MySQL默认没有密码,安装完毕增加密码的重要性是不言而喻的。
1、命令
六、启动与停止
1、启动
MySQL安装完成后启动文件mysql在/etc/init.d目录下,在需要启动时运行下面命令即可。
[root@test1 init.d]# /etc/init.d/mysql start
2、停止
/usr/bin/mysqladmin -u root -p shutdown
这样就把MySQL的数据文件移动到了/home/data/mysql下
4、找到f配置文件
如果/etc/目录下没有f配置文件,请到/usr/share/mysql/下找到*.cnf文件,拷贝其中一个到/etc/并改名为f)中。
命令如下:
socket = /home/data/mysql/mysql.sock (加上此行)
6、修改MySQL启动脚本/etc/rc.d/init.d/mysql
最后,需要修改MySQL启动脚本/etc/rc.d/init.d/mysql,把其中datadir=/var/lib/mysql一行中,等号右边的路径改成你现在
2、安装MySQL
rpm文件是Red Hat公司开发的软件安装包,rpm可让Linux在安装软件包时免除许多复杂的手续。该命令在安装时常用的参数是
–ivh ,其中i表示将安装指定的rmp软件包,V表示安装时的详细信息,h表示在安装期间出现“#”符号来显示目前的安装过程。这个
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h test1 password 'new-password'
。。。。。。(省略显示)
Starting mysqld daemon with databases from /var/lib/mysql
录非常重要,尤其对于Linux的初学者,因为 Linux本身的目录结构就比较复杂,如果搞不清楚MySQL的安装目录那就无从谈起深入学
习。
下面就介绍一下这几个目录。
1、数据库目录
/var/lib/mysql/
2、配置文件
/usr/share/mysql(mysql.server命令及配置文件)
值为:/home/mysql/mysql.sock 。操作如下:
vi f (用vi工具编辑f文件,找到下列数据修改之)
# The MySQL server
[mysqld]
port = 3306
#socket = /var/lib/mysql/mysql.sock(原内容,为了更稳妥用“#”注释此行)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
2)安装客户端
运行如下命令:
[root@test1 local]# rpm -ivh MySQL-client-5.0.22-0.i386.rpm
一、引言
想使用Linux已经很长时间了,由于没有硬性任务一直也没有系统学习,近日由于工作需要必须使用Linux下的MySQL。本以为有
Windows下使用SQL Server的经验,觉得在Linux下安装MySql应该是易如反掌的事,可在真正安装和使用MySQL时走了很多弯路,遇见
1:MySQL-client ########################################### [100%]
显示安装完毕。
用下面的命令连接mysql,测试是否成功。
三、登录MySQL
登录MySQL的命令是mysql, mysql 的使用语法如下:
3、自动启动
1)察看mysql是否在自动启动列表中
[root@test1 local]# /sbin/chkconfig –list
2)把MySQL添加到你系统的启动服务组里面去
[root@test1 local]# /sbin/chkconfig – add mysql
3)把MySQL从启动服务组里面删除。
[root@test1 local]# /sbin/chkconfig – del mysql
七、更改MySQL目录
MySQL默认的数据文件存储目录为/var/lib/mysql。假如要把目录移到/home/data下需要进行下面几步:
1、home目录下建立data目录
cd /home
mkdir data
2、把MySQL服务进程停掉:
mysqladmin -u root -p shutdown
3、把/var/lib/mysql整个目录移到/home/data
mv /var/lib/mysql /home/data/
mysql [-u username] [-h host] [-p[password]] [dbname]
username 与 password 分别是 MySQL 的用户名与密码,mysql的初始管理帐号是root,没有密码,注意:这个root用户不是
Linux的系统用户。MySQL默认用户是root,由于初始没有密码,第一次进时只需键入mysql即可。
注:因为开始时root没有密码,所以-p旧密码一项就可以省略了。
3、测试是否修改成功
1)不用密码登录
[root@test1 local]# mysql
ERROR 1045: Access denied for user: 'root@localhost' (Using password: NO)
Preparing... ########################################### [100%]
1:MySQL-server ########################################### [100%]
。。。。。。(省略显示)
[root@test1 mysql]# cp /usr/share/mysql/f /etc/f
5、编辑MySQL的配置文件/etc/f
为保证MySQL能够正常工作,需要指明mysql.sock文件的产生位置。修改socket=/var/lib/mysql/mysql.sock一行中等号右边的
符号将持续到安装完成后才停止。
1)安装服务器端
在有两个rmp文件的目录下运行如下命令:
[root@test1 local]# rpm -ivh MySQL-server-5.0.22-0.i386.rpm
显示如下信息。
warning: MySQL-server-5.0.9-0.i386.rpm: V3 DSA signature: NOKEY, key ID 5072e1f5
很多问题,毕竟Linux 和Windows本身就有很大区别。为了让和我一样的初学者在学习的过程中少走弯路,尽快入门,写了此文,希
望对您有所帮助。
二、安装Mysql
1、下载MySQL的安装文件
安装MySQL需要下面两个文件:
MySQL-server-5.0.22-0.i386.rpm
相关文档
最新文档