CentOS安装MySQL步骤

合集下载

虚拟机CentOS下MySQL的安装与配置

虚拟机CentOS下MySQL的安装与配置

CentOS下MySQL的安装与配置一、mysql是关系型数据库,可以去官网下载rpm包安装,但是也可以直接用yum二、卸载原有的mysql输入命令:# rpm –qa | grep mysql //查看是否安装了mysql。

使用# rpm –e mysql //普通删除模式。

# rpm –e –nodeps mysql //强力删除模式,若上个命令删除时有提示依赖项,次命令可以强力删除。

三、通过yum安装mysql# yum list | grep mysql //查看yum提供的mysql可以下载的版本然后# yum install –y mysql-server mysql mysql-deve // 安装mysql、mysql-server、mysql-deve即客户端和服务器安装完毕!四、mysql的初始化安装完mysql后,就会多处一个mysqld的服务,此就是数据库服务,可以输入# service mysqld start 命令启动mysqld服务。

第一次启动会有很多提示信息,那是在进行初始化配置,下一次启动就不会有了,就像:我们在使用mysql数据库的时候,都要先启动mysqld,我们可以将mysqld服务设置成开机启动,免得每次我们都要去启动一下。

通过# chkconfig mysqld on 设置Mysql安装完后只有一个root管理员账户,没有密码,我们可以为root帐号设置密码(这个为mysql的root账户,不是linux的root账户)# mysqladmin –u root password ‘new pw’然后通过mysql –u root –p 命令登陆我们的mysql五、mysql的主要配置文件1、/etc/f这是mysql的主配置文件我们可以查看一下一些信息2、/var/lib/mysql 这是mysql数据库的数据库文件存放位置3、/var/log 是mysql数据库的日志输出存放位置4、因为mysql数据库是可以通过网络访问的,并不是一个单机版数据库,其中使用的协议是tcp/ip协议,mysql数据库绑定的端口号是3306,我们可以通过# netstat –anp查看一下,Linux系统是否在监听3306这个端口号六、windows客户端远程访问linux下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。

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 启动的时候就会⾃动读取这个配置⽂件。

Centos 安装与配置 jdk、tomcat、mysql

Centos 安装与配置 jdk、tomcat、mysql

Centos 装jdk、tomcat1. 安装jdk·将下载下来的jdk-7u7-linux-i586.rpm通过ftp上传到linux服务器。

·检查系统是否已经安装了jdk:#rpm –qa | grep jdk //查看系统中已经安装的程序包含jdk的Centos 默认情况下会出现:java-1.6.0-openjdk-1.6.0.0-1.22.1.9.8.el5_6·首先卸载原有的jdk:#yum –y remove java-1.6.0-openjdk-1.6.0.0-1.22.1.9.8.el5_6#yum –y remove java*·卸载完成后重新安装:#rpm –ivh jdk-7u7-linux-i586.rpm //安装#rpm –qa | grep jdk //检查安装情况出现:jdk-1.7.0_07-fcs //表示已经安装成功·执行java javac 都可以看到相应的帮助信息,也可执行java –version 查看安装jdk的版本号,看到与所安装的jdk版本号相对应的版本号表示安装成功。

Jdk的安装目录一般是在:/usr/java下会根据jdk的版本再创建一个目录,如:/usr/java/jdk1.7.0_07·配置环境变量:#vi /etc/profile//在文件末尾添加:JA V A_HOME=/usr/java/jdk1.7.0_07PATH=$PATH:$JA V A_HOME/binCLASSPATH=.:$JA V A_HOME/lib/dt.jar:$JA V A_HOME/bli/tools.jar:$JA V A_HOM E/libJRE_HOME=$JA V A_HOME/jre存盘退出#export JA V A_HOME PATH CLASSPATH JRE_HOME //分发配置#source /etc/profile //重新执行配置2. 安装tomcat·将下载下来的apache-tomcat-6.0.20.tar.gz通过ftp上传到linux服务器。

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通,连数据库却不通。

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

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

centos下MySQLLinux Generic 安装步骤

centos下MySQLLinux Generic 安装步骤
touch/data/mysql/mysql.pid
6、启动mysql5.6.26服务
?
1
/usr/local/mysql/bin/mysqld_safe--defaults-file=./f--user=mysql&
如果没有报错,且日志文件/usr/local/mysql/mysqld.log里没有错误信息,基本就已经启动好了,可以通过ps查看进程
2、下载之后,解压安装包
?
1
tar-zxvfmysql-5.6.26-linux-glibc2.5-x86_64.tar.gz
然后通过cp指令复制解压出来的文件夹草/usr/local/mysql/(一定要将安装文件复制到mysql的安装目录下)
?
1
cp-frmysql-5.6.26-linux-glibc2.5-x86_64/*mysql
18
19
20
21
22
23
24
25
cat/etc/f
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
3、创建用户(如果已创建,忽略此步骤)
?
1
2
groupaddmysql
useradd-gmysqlmysql
4、安装mysql5.6.26
?
1
/usr/local/mysql/scripts/mysql_install_db--basedir=/usr/local/mysql--datadir=/data/mysql--user=mysql

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

Centos以RPM安装MySQL5.7.13

Centos以RPM安装MySQL5.7.13

CentOS6.7以RPM安装MySQL 5.7.13 2016年6月26日目录CentOS6.7以RPM安装MySQL 5.7.13 (2)一、安装介质准备: (2)二、MySQL安装过程: (2)CentOS6.7以RPM安装MySQL 5.7.13一、安装介质准备:1. mysql-community-client-5.7.13-1.el6.x86_64.rpm2. mysql-community-common-5.7.13-1.el6.x86_64.rpm3. mysql-community-libs-5.7.13-1.el6.x86_64.rpm4. mysql-community-server-5.7.13-1.el6.x86_64.rpm二、MySQL安装过程:1.查看服务器是否自带MySQL组件:rpm –qa | grepmysql输出结果如下:2.删除自带MySQL:rpm -e –nodeps mysql-libs-5.1.73-5.el6_6.x86_643.安装MySQL:rpm –ivh mysql-community-common-5.7.13-1.el6.x86_64.rpmrpm –ivhmysql-community-libs-5.7.13-1.el6.x86_64.rpmrpm –ivhmysql-community-client-5.7.13-1.el6.x86_64.rpmrpm –ivhmysql-community-server-5.7.13-1.el6.x86_64.rpm注意:是依次执行,不要乱了顺序,因为它们之间有依赖关系。

4.MySQL数据库初始化:(1).于mysql版本升级的原因,初始化要用到的mysqld命令不在之前的/usr/local/mysql 目录,所以我们要进行查找。

(2).Unix和Unix系列系统中,有一点是很重要的,那就是确保数据库目录与文件的所有者为mysql登录账户,以便在你运行mysqld服务的时候,mysql服务可以对这些目录和文件进行读取与写入操作。

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

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

2012年5月31日centos install mysql info:1. 下载cmake#tar -zvxf cmake-2.8.3.tar.gz3)、配置编译#cd cmake-2.8.3#yum -y install gcc //系统提示已安装!#yum -y install gcc-c++ //提示 HTTP 404 被禁止,但最后安装成功!# ./configure#make#make install# cd /usr/local/src/2、安装MySQL步骤2)、添加必要的组和拥有者#groupadd mysql#useradd -r -g mysql mysql3)、解压MySQL#tar -zvxf mysql-5.5.8.tar.gz4)、配置编译# mkdir /usr/local/mysql#mkdir /usr/local/mysql/data#cd /usr/local/src/mysql-5.5.8#cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DINSTALL_DATADIR=/usr/local/mysql/data \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DENABLED_LOCAL_INFILE=1//注意:上面的一段字符串是一条命令语句。

参数说明:-DCMAKE_INSTALL_PREFIX=/usr/local/mysql //安装目录-DINSTALL_DATADIR=/usr/local/mysql/data //数据库存放目录-DDEFAULT_CHARSET=utf8 //使用utf8字符-DDEFAULT_COLLATION=utf8_general_ci //校验字符-DEXTRA_CHARSETS=all //安装所有扩展字符集-DENABLED_LOCAL_INFILE=1 //允许从本地导入数据//报错:-- Could NOT find Curses (missing: CURSES_LIBRARYCURSES_INCLUDE_PATH)CMake Error at cmake/readline.cmake:82 (MESSAGE):Curses library not found. Please install appropriate package,remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.Call Stack (most recent call first):cmake/readline.cmake:126 (FIND_CURSES)cmake/readline.cmake:216 (MYSQL_USE_BUNDLED_LIBEDIT)CMakeLists.txt:256 (MYSQL_CHECK_READLINE)-- Configuring incomplete, errors occurred!----------------解决方法---------安装ncurses-devel:yum –y install ncurses-devel#find / -name CMakeCache.txt //查找所有CMakeCache.txt 文件命令会显示下列内容:/usr/local/src/cmake-2.8.3/CMakeCache.txt/usr/local/src/cmake-2.8.3/Tests/ComplexOneConfig/Cache/CMakeCache.txt/usr/local/src/cmake-2.8.3/Tests/CMakeFiles/CheckFortran/CMakeCache.txt/usr/local/src/cmake-2.8.3/Tests/Complex/Cache/CMakeCache.txt/usr/local/src/cmake-2.8.3/Tests/ComplexRelativePaths/Cache/CMakeCache.txt/usr/local/src/mysql-5.5.8/CMakeCache.txt删除下列内容:# rm -rf /usr/local/src/cmake-2.8.6/Tests/Complex/Cache/CMakeCache.txt# rm -rf /usr/local/src/cmake-2.8.6/Tests/ComplexOneConfig/Cache/CMakeCache.txt# rm -rf /usr/local/src/cmake-2.8.6/Tests/ComplexRelativePaths/Cache/CMakeCache.txt# rm -rf /usr/local/src/mysql-5.5.8/CMakeCache.txt再次执行命令: #cmake . \-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \-DINSTALL_DATADIR=/usr/local/mysql/data \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci \-DEXTRA_CHARSETS=all \-DENABLED_LOCAL_INFILE=1//执行成功!#make//过程中出现警告:类型双关作用在不完全类型上可能被破坏强重叠规则//警告:提领类型双关的指针将破坏强重叠规则.//如果make命令执行成功的话这些警告便忽略不计。

#make install4)、设置目录权限# cd /usr/local/mysql# chown -R root:mysql . //注意后面的“.”不要漏掉,表示把当前目录中所有文件的所有者所有者设为root,所属组为mysql# chown -R mysql:mysql data5)、配置文件# cp support-files/f /etc/f //这个配置仅适合小内存系统(32M - 64M)打开如下注释:innodb_data_home_dir = /usr/local/mysql/datainnodb_data_file_path = ibdata1:10M:autoextendinnodb_log_group_home_dir = /usr/local/mysql/datainnodb_buffer_pool_size = 16Minnodb_additional_mem_pool_size = 2Minnodb_log_file_size = 5Minnodb_log_buffer_size = 8Minnodb_flush_log_at_trx_commit = 1innodb_lock_wait_timeout = 50添加内容:[mysqld]max_connections = 10000 //根据服务器性能调节basedir = /usr/local/mysql //设置安装目录,这样在系统启动时才能正确运行到/etc/rc.d/init.d/mysql start6)、创建系统数据库的表# cd /usr/local/mysql# scripts/mysql_install_db --user=mysql7)、设置权限启动设置环境变量:# vi /root/.bash_profile在PATH=$PATH:$HOME/bin添加参数为:PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/mysql/lib#source /root/.bash_profile手动启动MySQL:# cd /usr/local/mysql# ./bin/mysqld_safe --user=mysql & //启动MySQL,但不能停止//启动日志写在此文件下:/usr/local/mysql/data/localhost.localdomain.err关闭MySQL服务# mysqladmin -u root -p shutdown //这里MySQL的root用户还没有配置密码,所以为空值。

通过脚本启动MySQL:# ln -s /usr/local/mysql/support-files/mysql.server /usr/local/mysql# mysql.server start //启动mysql# mysql.server stop //停止mysql//如果提示找不到命令则输入:/usr/local/mysql/support-files/mysql.server start 启动数据库8)、修改MySQL的root用户的密码:# mysql -u root mysqlmysql>use mysql;mysql>desc user;mysql>update user set Password = password('jyxjyx123') where User='root';mysql>select Host,User,Password from user where User='root';mysql>flush privileges; // mysql 新设置用户或更改密码后需用flush privileges刷新MySQL的系统权//限相关表,否则会出现拒绝访问mysql>exit //退出# netstat -tnl|grep 3306 //查看mysql端口是否存在。

远程连接出错但服务器本机能启动数据库:SQL Error (2003):Can't connect to MySQL server on (1065)远程ping服务器端口 telnet ip 3306命令行出现:连接中。

表示失败,原因是被服务器的防火墙拦截。

处理方法:在服务器终端运行以下命令:#iptables –F#iptables –X//上述命令会将服务器防火墙归0再次连接数据库服务器:出错: SQL Error (1130): Host IP is not allowed to connect to thisMySQL server再次用windows命令行ping 被mysql拒绝,表示之前的修改有效,此次被mysql拒绝。

相关文档
最新文档