centos7 mysql数据库安装和配置

2016-5-6 liyangweb.com 李杨 服务器

一、系统环境

yum update升级以后的系统版本为

[root@yl-web yl]# cat /etc/redhat-release  CentOS Linux release 7.1.1503 (Core) 

二、mysql安装

一般网上给出的资料都是

#yum install mysql #yum install mysql-server #yum install mysql-devel

安装mysql和mysql-devel都成功,但是安装mysql-server失败,如下:

[root@yl-web yl]# yum install mysql-server Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile * base: mirrors.sina.cn * extras: mirrors.sina.cn * updates: mirrors.sina.cn
No package mysql-server available.
Error: Nothing to do

查资料发现是CentOS 7 版本将MySQL数据库软件从默认的程序列表中移除,用mariadb代替了。

有两种解决办法:

1、方法一:安装mariadb

MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可。开发这个分支的原因之一是:甲骨文公司收购了MySQL后,有将MySQL闭源的潜在风险,因此社区采用分支的方式来避开这个风险。MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。

安装mariadb,大小59 M。

[root@yl-web yl]# yum install mariadb-server mariadb 

mariadb数据库的相关命令是:

systemctl start mariadb  #启动MariaDB

systemctl stop mariadb  #停止MariaDB

systemctl restart mariadb  #重启MariaDB

systemctl enable mariadb  #设置开机启动

所以先启动数据库

[root@yl-web yl]# systemctl start mariadb

然后就可以正常使用mysql了

[root@yl-web yl]# mysql -u root -p Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3 Server version: 5.5.41-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases; +--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)

MariaDB [(none)]> 

安装mariadb后显示的也是 MariaDB [(none)]> ,可能看起来有点不习惯。下面是第二种方法。

2、方法二:官网下载安装mysql-server

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm # rpm -ivh mysql-community-release-el7-5.noarch.rpm # yum install mysql-community-server

安装成功后重启mysql服务。

# service mysqld restart

初次安装mysql,root账户没有密码。

[root@yl-web yl]# mysql -u root  Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 Server version: 5.6.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases; +--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.01 sec)

mysql> 

设置密码

mysql> set password for 'root'@'localhost' =password('password');
Query OK, 0 rows affected (0.00 sec)

mysql> 

不需要重启数据库即可生效。

在mysql安装过程中如下内容:

Installed:
  mysql-community-client.x86_64 0:5.6.26-2.el7                mysql-community-devel.x86_64 0:5.6.26-2.el7                
  mysql-community-libs.x86_64 0:5.6.26-2.el7                  mysql-community-server.x86_64 0:5.6.26-2.el7               

Dependency Installed:
  mysql-community-common.x86_64 0:5.6.26-2.el7                                                                            

Replaced:
  mariadb.x86_64 1:5.5.41-2.el7_0          mariadb-devel.x86_64 1:5.5.41-2.el7_0   mariadb-libs.x86_64 1:5.5.41-2.el7_0  
  mariadb-server.x86_64 1:5.5.41-2.el7_0  

所以安装完以后mariadb自动就被替换了,将不再生效。

[root@yl-web yl]# rpm -qa |grep mariadb [root@yl-web yl]# 

三、配置mysql

1、编码

mysql配置文件为/etc/my.cnf

最后加上编码配置

[mysql]
default-character-set =utf8

这里的字符编码必须和/usr/share/mysql/charsets/Index.xml中一致。

2、远程连接设置

把在所有数据库的所有表的所有权限赋值给位于所有IP地址的root用户。

mysql> grant all privileges on *.* to root@'%'identified by 'password';

如果是新用户而不是root,则要先新建用户

mysql>create user 'username'@'%' identified by 'password';  

此时就可以进行远程连接了。

 

转自:http://www.cnblogs.com/starof/p/4680083.html

标签: Linux mysql

评论:

alikexue
2019-02-17 21:04
<a href="http://www.redstonecloud.com/nike-arizona-cardinals-heart-soul-nfl-t-shirt-red-nflr">nike arizona cardinals heart soul nfl t shirt red</a> <a href="http://www.thepoolfloats.com/nike-flyknit-racer-jaune-or-butyg">nike flyknit racer jaune or</a> <a href="http://www.tsgctt.com/womens-nike-kansas-city-chiefs-50-justin-houston-limited-blackgold-salute-to-service-nfl-jersey-nflz">womens nike kansas city chiefs 50 justin houston limited blackgold salute to service nfl jersey</a> <a href="http://www.virginiaflyin.com/youth-isaac-seumalo-limited-camo-nike-jersey-nfl-philadelphia-eagles-73-2018-salute-to-service-nflw">youth isaac seumalo limited camo nike jersey nfl philadelphia eagles 73 2018 salute to service</a> <a href="http://www.bandbwhitby.com/jordan-11-tout-bleu-chaussuresa">jordan 11 tout bleu</a> <a href="http://www.funkymediamx.com/nike-air-max-90-em-sort-gr%C3%B8n-neon-butya">nike air max 90 em sort gr酶n neon</a>
alikexue http://www.alikexue.com/
tmzred
2019-02-10 09:44
<a href="http://www.thebiarritz.com/indiana-hoosiers-new-era-ncaa-washed-neo-39thirty-cap-hath">indiana hoosiers new era ncaa washed neo 39thirty cap</a> <a href="http://www.voydnet.com/femmes-air-max-90-hyperfuse-violet-jaune-chaussuresh">femmes air max 90 hyperfuse violet jaune</a> <a href="http://www.foneandlone.com/under-armour-curry-one-vert-rose-chaussuresj">under armour curry one vert rose</a> <a href="http://www.roomwhiz.com/nike-lebron-witness-rosa-gold-schuhej">nike lebron witness rosa gold</a> <a href="http://www.riffsurfers.com/adidas-soccers-sko-lyser%C3%B8d-sort-skok">adidas soccers sko lyser酶d sort</a> <a href="http://www.davidmgaines.com/femminile-air-jordan-retro-10-grigio-nero-scarpeh">femminile air jordan retro 10 grigio nero</a>
tmzred http://www.tmzred.com/
dvmengineers
2019-01-27 16:32
<a href="http://www.georgesherry.com/a-buon-mercato-nike-air-pegasus-92-maschio-oro-skoa">a buon mercato nike air pegasus 92 maschio oro</a> <a href="http://www.jenalgroup.com/jordan-retro-3-black-cement-2013-sneakere">jordan retro 3 black cement 2013</a> <a href="http://www.badacamshotel.com/air-jordan-retro-10-hvid-orange-kurpesa">air jordan retro 10 hvid orange</a> <a href="http://www.compressmyjs.com/billig-under-armour-curry-3-herre-gr%C3%B8n-sneakerb">billig under armour curry 3 herre gr酶n</a> <a href="http://www.fetison.com/air-jordan-after-game-mens-black-grey-shoesg">air jordan after game mens black grey</a> <a href="http://www.neffloot.com/indianapolis-colts-bucket-hat-hats">indianapolis colts bucket hat</a>
dvmengineers http://www.dvmengineers.com/
medicinennet
2019-01-19 04:05
<a href="http://www.eryasaat.com/air-jordan-super-fly-marrone-argento-kurpesb">air jordan super fly marrone argento</a> <a href="http://www.peoplesbit.com/dam%C3%A4nner-nike-free-run-2-schwarz-grau-schuhed">dam盲nner nike free run 2 schwarz grau</a> <a href="http://www.tikidood.com/free-run-4.0-v3-rosa-volume-schuheg">free run 4.0 v3 rosa volume</a> <a href="http://www.vrpraying.com/kvinners-nike-air-max-bw-r%C3%B8d-gul-kurpesd">kvinners nike air max bw r酶d gul</a> <a href="http://www.adamaccademia.com/girls-toddler-air-jordan-retro-1-mid-basketballe-schuhe-obuvg">girls toddler air jordan retro 1 mid basketballe schuhe</a> <a href="http://www.jesusinprison.com/nike-air-max-1-essential-wolf-gris-negro-scarpee">nike air max 1 essential wolf gris negro</a>
medicinennet http://www.medicinennet.com/
vegashideas
2019-01-10 07:02
<a href="http://www.evorewards.com/nike-air-force-1-mid-marrone-obuvf">nike air force 1 mid marrone</a> <a href="http://www.kfmimarlik.com/salomon-speed-cross-3-gr%C3%B8nn-gr%C3%A5-obuvd">salomon speed cross 3 gr酶nn gr氓</a> <a href="http://www.larozena.com/nike-zoom-alle-out-lila-orange-kurpesg">nike zoom alle out lila orange</a> <a href="http://www.lebosmartlipo.com/nike-free-trainer-5.0-nrg-jerry-rice-for-verkauf-obuvb">nike free trainer 5.0 nrg jerry rice for verkauf</a> <a href="http://www.mobilsevgili.com/nike-air-max-lunar-1-vert-orange-butya">nike air max lunar 1 vert orange</a> <a href="http://www.ochapan.com/nike-youth-mike-pouncey-limited-olivecamo-jersey-los-angeles-chargers-nfl-53-2017-salute-to-service-nflu">nike youth mike pouncey limited olivecamo jersey los angeles chargers nfl 53 2017 salute to service</a>
vegashideas http://www.vegashideas.com/
miendiation
2019-01-03 14:07
<a href="http://www.bhcsboosters.com/green-pink-womens-air-jordan-retro-8-shoes-runninge">green pink womens air jordan retro 8 shoes</a> <a href="http://www.denisgoulart.com/kevin-hart-announces-the-release-of-the-nike-hustle-hart-2-zapatosu">kevin hart announces the release of the nike hustle hart 2</a> <a href="http://www.donggeomdo.com/nike-kd-vii-big-b%C3%B8rn-lilla-gr%C3%A5-chaussuresa">nike kd vii big b酶rn lilla gr氓</a> <a href="http://www.ozoessaouira.com/39-game-stanley-havili-indianapolis-colts-jersey-road-white-nfle">39 game stanley havili indianapolis colts jersey road white</a> <a href="http://www.annomaplexel.com/nike-shox-women-purple-runningg">nike shox women purple</a> <a href="http://www.bringribben.com/women-2012-new-nfl-jerseys-san-francisco-49ers-53-navorro-bowman-red-jerseys-hall-of-fames-50th-patch-nflv">women 2012 new nfl jerseys san francisco 49ers 53 navorro bowman red jerseys hall of fames 50th patch</a>
miendiation http://www.miendiation.com/
crisgarrett
2018-12-31 05:23
<a href="http://www.mikespothole.com/nike-lunar-3-multicolor-sneakerb">nike lunar 3 multicolor</a> <a href="http://www.theclaydoctor.com/womens-nike-air-huarache-light-yellow-purple-shoesf">womens nike air huarache light yellow purple</a> <a href="http://www.allthatspool.com/star-wars-new-era-hat-hats">star wars new era hat</a> <a href="http://www.ihavewed.com/flyknit-roshe-run-sizing-software-sneakere">flyknit roshe run sizing software</a> <a href="http://www.cloudsmartin.com/dam%C3%A4nner-nike-lunarglide-6-gr%C3%BCn-rosa-obuvc">dam盲nner nike lunarglide 6 gr眉n rosa</a> <a href="http://www.myachingoa.com/rebels-blank-red-stitched-ncaa-jersey-nflx">rebels blank red stitched ncaa jersey</a>
crisgarrett http://www.crisgarrett.com/
forbezdynasty
2018-12-30 16:31
<a href="http://www.fhomestudio.com/nike-graham-glasgow-black-name-number-logo-detroit-lions-nfl-60-long-sleeve-t-shirt-nfls">nike graham glasgow black name number logo detroit lions nfl 60 long sleeve t shirt</a> <a href="http://www.ktfinans.com/dam%C3%A4nner-ralph-lauren-mesh-polo-lila-schwarz-polox">dam盲nner ralph lauren mesh polo lila schwarz</a> <a href="http://www.ladivorcecpa.com/womens-nike-los-angeles-rams-4-greg-zuerlein-game-white-nfl-jersey-nflz">womens nike los angeles rams 4 greg zuerlein game white nfl jersey</a> <a href="http://www.moxiepouch.com/nike-free-run-3-5.0-rojo-blanco-kurpesd">nike free run 3 5.0 rojo blanco</a> <a href="http://www.pepsisite.com/nike-limited-rashaad-penny-jersey-20-nfl-seattle-seahawks-vapor-untouchable-womens-home-navy-blue-nflz">nike limited rashaad penny jersey 20 nfl seattle seahawks vapor untouchable womens home navy blue</a> <a href="http://www.watfashion.com/nike-air-max-2014-femminile-viola-rosa-obuve">nike air max 2014 femminile viola rosa</a>
forbezdynasty http://www.forbezdynasty.com/
pandrosos
2018-12-30 03:34
<a href="http://www.rcnbundles.com/nike-zoom-pegasus-33-gris-azul-scarpeb">nike zoom pegasus 33 gris azul</a> <a href="http://www.whoreregistry.com/olympic-2014-ca-8-drew-doughty-black-stitched-nhl-jersey-nfls">olympic 2014 ca 8 drew doughty black stitched nhl jersey</a> <a href="http://www.desingbrain.com/adidas-superstar-2-blanco-and-armada-scarpeg">adidas superstar 2 blanco and armada</a> <a href="http://www.maytumcompany.com/yeezy-boost-550-gr%C3%A5-sort-obuvd">yeezy boost 550 gr氓 sort</a> <a href="http://www.parsoniidrs.com/air-jordan-b-mo-s%C3%B8lv-sort-scarpea">air jordan b mo s酶lv sort</a> <a href="http://www.petcareomaha.com/nike-air-max-tailwind-6-nero-femminile-yoga-schuheb">nike air max tailwind 6 nero femminile yoga</a>
pandrosos http://www.pandrosos.com/
dystopianflix
2018-12-29 15:03
<a href="http://www.opticgambetta.com/t%C3%AAnis-nike-shox-nz-eu-masculino-skor">t锚nis nike shox nz eu masculino</a> <a href="http://www.purofairtrade.com/louboutin-shoes-black-pumps-louboutinr">louboutin shoes black pumps</a> <a href="http://www.zendounagota.com/new-balance-996-grey-and-white-trainers-skor">new balance 996 grey and white trainers</a> <a href="http://www.modambalaj.com/cortez-allen-28-jersey-year-nfld">cortez allen 28 jersey year</a> <a href="http://www.nowosadko.com/atlanta-braves-jersey-personalized-nflg">atlanta braves jersey personalized</a> <a href="http://www.advitil.com/authentic-troy-aikman-throwback-jersey-dallas-cowboys-8-black-shadow-reebok-nfla">authentic troy aikman throwback jersey dallas cowboys 8 black shadow reebok</a>
[url=http://www.dystopianflix.com/]dystopianflix[/url]
esterbed
2018-12-27 16:15
<a href="http://www.tjharkins.com/light-bleu-cashmere-ralph-lauren-sweater-in-hommes-polou">light bleu cashmere ralph lauren sweater in hommes</a> <a href="http://www.yolohostelrio.com/air-max-zero-night-maroon-atomic-rosa-kvinners-chaussuresa">air max zero night maroon atomic rosa kvinners</a> <a href="http://www.askforpauline.com/hombres-nike-shox-current-naranja-oro-schuhee">hombres nike shox current naranja oro</a> <a href="http://www.bringussocial.com/nike-free-rn-flyknit-mennns-l%C3%B8ping-sko-you-scarpea">nike free rn flyknit mennns l酶ping sko you</a> <a href="http://www.ecoforplanet.com/kyrie-1-cereal-chaussures-kurpese">kyrie 1 cereal chaussures</a> <a href="http://www.mbesthetics.com/sweden-25-rinne-home-soccer-country-jersey-nflr">sweden 25 rinne home soccer country jersey</a>
esterbed http://www.esterbed.com/

发表评论:

Powered by emlog 冀ICP备13011830号-1