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

合集下载

【MySQL】源码编译安装和配置MySql5.5.32(单实例)

【MySQL】源码编译安装和配置MySql5.5.32(单实例)

【MySQL】源码编译安装和配置MySql5.5.32(单实例)【需求描述】在CentOS环境中,通过编译源码的⽅式,安装并且配置“单实例”的MySQL5.5.32数据库。

MySQL的安装⽬录为:/application/mysql-5.5.32MySQL数据⽂件的安装⽬录为:/application/mysql-5.5.32/dataMySQL默认的字符编码为:UTF8【环境参数】VMware:10.0.1Host:Win7DB:MySql 5.5.32编译⼯具:cmake-2.8.8.tar.gz其他依赖:ncurses-devel-5.7-3.20090208.el6.x86_64.rpmClient:CentOS 6.5 x86_64,i686,最⼩化安装(Minimal)。

在安装⾃定义组件包时,(1)Base System只安装了Base,Compatibility Libraries和Debugging Tools。

(2)Development只安装了Development Tools。

【软件下载】(1)MySql下载地址:选择“Generic Linux (Architecture Independent), Compressed TAR Archive”这个版本的来下载。

(2)下载cmakeCMake是⼀个跨平台的安装(编译)⼯具,可以⽤简单的语句来描述所有平台的安装(编译过程)。

他能够输出各种各样的makefile或者project⽂件,能测试编译器所⽀持的C++特性,类似UNIX下的automake。

只是 CMake 的组态档取名为 CmakeLists.txt。

(3)下载ncurse-devel依赖包的百度云盘分享:【具体步骤】1、查看系统环境[root@centos65-mini ~]# cat /etc/redhat-releaseCentOS release 6.5 (Final)[root@centos65-mini ~]#[root@centos65-mini ~]#[root@centos65-mini ~]# uname -r2.6.32-431.el6.x86_64[root@centos65-mini ~]#2、安装相关软件包(1) 配置、编译和安装cmake编译⼯具①在当前⽬录,解压缩cmake-2.8.8.tar.gz# tar –zxvf cmake-2.8.8.tar.gz②从当前⽬录切换到cmake-2.8.8⽬录中,# cd cmake-2.8.8③执⾏命令“#./configure”来配置cmake⼯具。

CentOS_6.6用rpm方式安装MySql

CentOS_6.6用rpm方式安装MySql

CentOS_6.6用rpm方式安装MySql卸载旧版本MySql检查MySQL及相关RPM包,是否安装,如果有安装,则移除[root@MyServer010 ftp]# rpm -qa|grep mysqlmysql-libs-5.1.73-3.el6_5.x86_64[root@MyServer010 ftp]# yum -y remove mysql-libs*移除MySql也可以用下面的命令rpm -e --nodeps mysql-libs-5.1.73-3.el6_5.x86_64下载的MySql文件[root@MyServer010 ftp]# ll-rw-r--r-- 1 root root 18596528 10月21 14:31 MySQL-client-5.6.27-1.el6.x86_64.rpm-rw-r--r-- 1 root root 3392620 10月21 14:31 MySQL-devel-5.6.27-1.el6.x86_64.rpm-rw-r--r-- 1 root root 55950588 10月21 14:32 MySQL-server-5.6.27-1.el6.x86_64.rpm安装MySql[root@MyServer010 ftp]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm注意:安装server时,会有下面的提示,会告知root第一次登录所需的随机密码文件位置。

A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !You will find that password in '/root/.mysql_secret'.You must change that password on your first connect,no other statement but 'SET PASSWORD' will be accepted.See the manual for the semantics of the 'password expired' flag.Also, the account for the anonymous user has been removed.In addition, you can run:/usr/bin/mysql_secure_installation下面接着安装[root@MyServer010 ftp]# rpm -ivh MySQL-devel-5.6.27-1.el6.x86_64.rpm[root@MyServer010 ftp]# rpm -ivh MySQL-client-5.6.27-1.el6.x86_64.rpm初始化数据库及设置密码[root@MyServer010 ftp]# /usr/bin/mysql_install_db[root@MyServer010 ftp]# service mysql startStarting MySQL.. SUCCESS![root@MyServer010 ftp]# cat /root/.mysql_secret# The random password set for the root user at Wed Oct 21 14:56:09 2015 (local time): _zh41DmKP_Zzw7vn密码为红字,下面登录MySql[root@MyServer010 ftp]# mysql -uroot -p_zh41DmKP_Zzw7vn修改密码:mysql> set password = password('admin');Query OK, 0 rows affected (0.00 sec)mysql> exit;[root@MyServer010 ftp]# mysql -uroot -padmin以新密码登录成功,则表示新密码设置完成。

CentOS下Apache、PHP、MySQL安装配置

CentOS下Apache、PHP、MySQL安装配置

1. 安装Apahce, PHP,以及php连接mysql库组件。

yum -y install httpd php php-mysql2. 配置开机启动服务/sbin/chkconfig httpd on [设置apache服务器httpd服务开机启动]/sbin/chkconfig --add mysqld [在服务清单中添加mysql服务]/sbin/chkconfig mysqld on [设置mysql服务开机启动]/sbin/service httpd start [启动httpd服务,与开机启动无关]3.//安装apache扩展yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql//安装php的扩展yum install php-gdyum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc4.apache的配置文件是/etc/httpd/conf下modules放在/usr/lib/httpd下php的配置文件在/etc/php.d/下和/etc/php.iniphp的modules放在/usr/lib/php/modules下apache 默认支持php配置zendoptimizer-3.3.3 cd 目录install 安装过程指定httpd控制文件/etc/rc.d/init.d/httpd路径/etc/httpd配置cronolog进行日志分割下载/download/index.html./configure --prefix /usr/local/cronologmakemake install即可httpd-vhost.conf中的日志设置项可以为:ErrorLog “|/usr/local/cronolog/sbin/cronolog/home/www/apache_logs/-error_log%Y%m%d" CustomLog |/usr/local/cronolog/sbin/cronolog /home/www/apache_logs/-access_log%Y%m%d"combinedmount -t nfs 192.168.0.252:/home/www/wwwroot/bbs /home/www/wwwroot/bbs出现:Document root must be a directory解决办法?关闭selinux setenforce 01.前言CentOS(Community ENTerprise Operating System)是Linux发行版之一,它是来自于Red Hat Enterprise Linux依照开放源代码规定释出的源代码所编译而成。

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服务。

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

Centos7安装并配置mysql5.6完美教程

Centos7安装并配置mysql5.6完美教程

Centos7安装并配置mysql5.6完美教程Centos7将默认替换成了Mariadb,对于我们这些还想使⽤的开发⼈员来说并不是⼀个好消息。

然⽽,⽹上关于安装mysql数据库的教程数不胜数,但是,⼤多教程都是漏洞百出。

今天,为了帮助各位需要的⼈,从⽽写下Centos7安装配置mysql5.6的教程。

好了,话不多说,上教程:⼀、安装MySQL2、卸载系统⾃带的Mariadb打开Terminal终端:[root@localhost ~]# rpm -qa|grep mariadb // 查询出来已安装的mariadb[root@localhost ~]# rpm -e --nodeps ⽂件名 // 卸载mariadb,⽂件名为上述命令查询出来的⽂件3、删除etc⽬录下的f[root@localhost ~]# rm /etc/f4、执⾏以下命令来创建mysql⽤户组[root@localhost ~]# groupadd mysql5、执⾏以下命令来创建⼀个⽤户名为mysql的⽤户并加⼊mysql⽤户组[root@localhost ~]# useradd -g mysql mysql6、将下载的压缩包放到 /usr/local/ ⽬录下(通过mv 要移动的⽂件 /usr/local/)7、解压安装包[root@localhost ~]# tar -xvf mysql-5.6.34-linux-glibc2.5-x86_64.tar注:如果压缩包为:mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz,则解压命令为: tar -zxvf mysql-5.6.34-linux-glibc2.5-x86_64.tar.gz8、将解压好的⽂件夹重命名为mysql[root@localhost local]# mv 解压出来的⽂件夹名 mysql9、在 etc 下新建配置⽂件f,并在该⽂件中添加⼀下代码:当然,也有简单⽅式:直接copy⼀份f⽂件到/etc下,然后再修改即可。

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 MariaDB10(MySql)相关安装配置

CentOS7 MariaDB10(MySql)相关安装配置

依次依据自己的需要,点选下图中的1、2、3部分,最终会得到4部分内容。

[root@localhost /]# im /etc/yum.repos.d/MariaDB.repo
[root@localhost /]# yum makecache
[root@localhost /]# yum install mariadb-server mariadb-client
[root@localhost /]# rpm -qa|grep MariaDB
[root@localhost /]# mysql
最新稳定版本,估计与Oracle公司达成某个协议,可以看到上面截图中有如下这么一句话
连接Windows版本的MariaDB(在下载MariaDB 10的版本,会自带HeidiSQL),配置信息如下图:
的权限,需要予以调整。

调整顺序如下所示,调整完毕后,测试连接是成功的。

哦,对了,在这之前需要就爱那个CentOS的防火墙关掉,否则会网络会不通的,错误如下图:
关闭CentOS的处理方法如下图:。

Linux CentOS6.5下编译安装MySQL 5.6.16

Linux CentOS6.5下编译安装MySQL 5.6.16

一、编译安装MySQL前的准备工作安装编译源码所需的工具和库[sql]view plaincopy1.yum install gcc gcc-c++ ncurses-devel perl安装cmake,从下载源码并编译安装[sql]view plaincopy1.wget /files/v2.8/cmake-2.8.10.2.tar.gz2.tar -xzvf cmake-2.8.10.2.tar.gz3.cd cmake-2.8.10.24../bootstrap ; make ; make install5.cd ~二、设置MySQL用户和组新增mysql用户组[sql]view plaincopy1.groupadd mysql新增mysql用户[sql]view plaincopyeradd -r -g mysql mysql三、新建MySQL所需要的目录新建mysql安装目录[sql]view plaincopy1.mkdir -p /usr/local/mysql新建mysql数据库数据文件目录[sql]view plaincopy1.mkdir -p /data/mysqldb四、下载MySQL源码包并解压从/downloads/mysql/直接下载源码,解压mysql-5.6.16.tar.gz(/这个网站就是用的5.6.16版本)[sql]view plaincopy1.wget /files/mysql-5.6.16.tar.gz2.tar -zxv -f mysql-5.6.16.tar.gz3.cd mysql-5.6.16设置编译参数[sql]view plaincopy1.cmake \2.-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \3.-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock \4.-DDEFAULT_CHARSET=utf8 \5.-DDEFAULT_COLLATION=utf8_general_ci \6.-DWITH_INNOBASE_STORAGE_ENGINE=1 \7.-DWITH_ARCHIVE_STORAGE_ENGINE=1 \8.-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \9.-DMYSQL_DATADIR=/data/mysqldb \10.-DMYSQL_TCP_PORT=3306 \11.-DENABLE_DOWNLOADS=1注:重新运行配置,需要删除CMakeCache.txt文件[sql]view plaincopy1.rm CMakeCache.txt编译源码[sql]view plaincopy1.make安装[sql]view plaincopy1.make install六、修改mysql目录所有者和组修改mysql安装目录[sql]view plaincopy1.cd /usr/local/mysql2.chown -R mysql:mysql .修改mysql数据库文件目录[sql]view plaincopy1.cd /data/mysqldb2.chown -R mysql:mysql .七、初始化mysql数据库[sql]view plaincopy1.cd /usr/local/mysql2.scripts/mysql_install_db --user=mysql --datadir=/data/mysqldb八、复制mysql服务启动配置文件[sql]view plaincopy1.cp /usr/local/mysql/support-files/f /etc/f注:如果/etc/f文件存在,则覆盖。

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 最新版已经安装到我们的系统了,但这是还没有初始化数据,所以导致⽆法启动。

mysql数据库搭建流程

mysql数据库搭建流程

mysql数据库搭建流程MySQL是一种广泛使用的关系型数据库管理系统,是开源软件,各个平台上都可以使用,具有性能稳定、操作简易等优点,成为非常流行的数据库选择。

下面就来介绍一下MySQL数据库搭建流程。

1.安装MySQL数据库管理系统首先需要下载对应平台的MySQL安装包,这里以Windows平台为例。

下载完成后,双击运行安装程序,按照提示完成MySQL安装,在过程中需要设置MySQL的管理员账户和密码,并可以选择安装的组件。

2.配置MySQL服务在MySQL安装完成后,需要进行服务的配置。

在Windows平台下,打开“服务”管理器,找到MySQL服务,并启动服务。

如果MySQL服务启动失败,可能需要更改MySQL配置文件my.ini的默认路径,将MySQL程序路径修改为正确路径,即可启动服务。

3.创建数据库和用户在MySQL服务已经成功启动后,需要在MySQL中创建一个新数据库以及一个管理用户。

可以使用MySQL客户端工具,如MySQL Workbench等工具进行创建。

首先登录MySQL,在QUERY上输入CREATE DATABASE 数据库名字;,完成创建数据库。

然后在QUERY上输入CREATE USER '用户名称'@'localhost' IDENTIFIED BY '用户密码';,完成创建用户。

4.为用户授权完成用户的创建后,需要为其授权,以便用户可以对创建的数据库进行操作。

使用GRANT语句进行授权,在QUERY上输入GRANT ALL PRIVILEGES ON 数据库名字.* TO '用户名称'@'localhost' IDENTIFIED BY '用户密码';,完成用户的授权。

5.远程访问的配置如果需要让外部机器可以访问MySQL,则需要进行相关配置,如取消bind address、开放MySQL默认端口3306等。

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以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服务可以对这些目录和文件进行读取与写入操作。

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

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方法。

mysql数据库的user表中必须有远程用户,即把user表中的localhost改为%。

七、解决Access denied for user “”@’localhost’ to database ‘mysql’
1、停止mysqld服务
2、运行# mysqld_safe –skip-grant-tables &
3、再用root用户登陆。

相关文档
最新文档