centos7 安装 mysql

参考了下面两个连接html

http://www.centoscn.com/mysql/2016/0315/6844.html 连接Amysql

http://www.cnblogs.com/starof/p/4680083.html 连接Bsql


  • centos7再也不默认安装mysql,默认安装的是mariadb,在命令行里输入yum install mysql能够看到提示中显示要下载mariadb.centos

  • mariadb的安装能够参数连接B中的描述ide

  • 下面是从连接A中获取的安装mysql方法.url

    在/etc/yum.repos.d目录中添加一个文件mysql-community.repo,文件内容为centos7

  • #Enble to use MySQL 5.6
    [mysql56-community]
    name=MySQL 5.6 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/
    enabled=1
    gpgcheck=0
    gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  • 在命令行中输入,yum install mysql-community-server,便可以安装mysql,安装的是mysql5.6,若是系统中安装了mariadb,mysql的安装还会将mariadb删除.命令行

安装过程当中还遇到了一个问题server

没法安装mysql-InvalidGPGKeyfromfile:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql htm

这里参考了

http://www.2cto.com/database/201701/586216.html 

即将文件/etc/yum.repos.d/mysql-community.repo中的gpgcheck=1改为gpgcheck=0便可.

这是为何上面的文件与连接A中的文件内容不一样的缘由.


启动mysql

systemctl start  mysqld.service

初次安装mysql是root帐户是没有密码,须要设置一下,

mysql -h localhost -u root -p进入mysql

设置密码的时候遇到了问题

mysql> set password for ‘root’@‘localhost’ = password('123456');
ERROR 1133 (42000): Can't find any matching row in the user table

解决方法

mysql> grant all on mysql.user to 'root'@'%' identified by 'password';
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set password=password('123456') where user ='root';
Query OK, 5 rows affected (0.00 sec)
Rows matched: 5  Changed: 5  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
相关文章
相关标签/搜索