centos7 安装mysql

32 篇文章 0 订阅

yum install mysql mysql-devel mysql-server

是找不到mysql-server包的,因为Centos7中用MariaDB代替了mysql数据库。

查了资料,MariaDB是优于mysql的,但是我们开发环境全是用的mysql,并不敢轻易换,待我明天做下测试,如不影响现有产品的使用情况,再决定是否更新。

以下是装mysql-server的过程及出现问题的解决办法:

1、# 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


2、[root@localhost /]# whereis mysqld
mysqld: /usr/sbin/mysqld

[root@localhost /]#  mysqld

报如下错误:
Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
解决方法:
[root@localhost /]# mysql_install_db --user=mysql  初始化数据库即可


3、初次安装mysql是root账户是没有密码的

[root@localhost /]# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
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> insert into mysql.user(host,user,password) values("%","newmedia",password("newmedia123456"));

ERROR 1364 (HY000): Field 'ssl_cipher' doesn't have a default value
原因:在我的配置文件my.cnf中有这样一条语句
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
指定了严格模式,为了安全,严格模式禁止通过insert 这种形式直接修改mysql库中的user表进行添加新用户
解决办法:
将配置文件中的STRICT_TRANS_TABLES删掉,即改为:
sql_mode=NO_ENGINE_SUBSTITUTION
然后重启mysql即可
Query OK, 1 row affected, 3 warnings (0.00 sec)
mysql> GRANT ALL PRIVILEGES ON *.* TO 'newmedia' IDENTIFIED BY 'newmedia123456' WITH GRANT OPTION;
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH   PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> Ctrl-C -- exit!
Aborted

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值