wsaer 发表于 2018-10-9 12:38:26

centos7 安装 mysql

  参考了下面两个链接
  http://www.centoscn.com/mysql/2016/0315/6844.html 链接A
  http://www.cnblogs.com/starof/p/4680083.html 链接B

[*]  centos7不再默认安装mysql,默认安装的是mariadb,在命令行里输入yum install mysql可以看到提示中显示要下载mariadb.
[*]  mariadb的安装可以参数链接B中的描述
[*]  下面是从链接A中获取的安装mysql方法.
  在/etc/yum.repos.d目录中添加一个文件mysql-community.repo,文件内容为
[*]#Enble to use MySQL 5.6  

  
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删除.
  安装过程中还遇到了一个问题
  无法安装mysql-InvalidGPGKeyfromfile:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
  这里参考了
  http://www.iyunv.com/database/201701/586216.html
  即将文件/etc/yum.repos.d/mysql-community.repo中的gpgcheck=1改成gpgcheck=0即可.
  这是为什么上面的文件与链接A中的文件内容不同的原因.
  启动mysql
  systemctl startmysqld.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: 5Changed: 5Warnings: 0
  

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


页: [1]
查看完整版本: centos7 安装 mysql