zoukankan      html  css  js  c++  java
  • centos7安装mysql数据库并且授权问题

    centos7安装数据库步骤

    首先两种安装方式,第一种通过yum源安装mariadb;第二种通过安装mysql;

    yum -y install mysql
    yum -y install mariadb-server
    mysql_secure_installation 设置 root密码等相关

     当出现报错信息如下:

    140524 03:15:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
    140524  3:15:57 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it.
    140524  3:15:57  InnoDB: Initializing buffer pool, size = 8.0M
    140524  3:15:57  InnoDB: Completed initialization of buffer pool
    140524  3:15:57  InnoDB: Started; log sequence number 0 44233
    140524  3:15:57 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist
    140524 03:15:57 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended
    解决办法mysql_install_db
    --user=mysql --ldata=/var/lib/mysql/

    当出现

    ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
    把这个/var/lib/mysql路径下清空;
    
    systemctl start mysqld.service
    
    systemctl status mysqld.service
    
    当出现Failed to start mysqld.service: Unit mysqld.service failed to load: No such file or directory
    
    systemctl start mariadb.service
    
    systemctl enable mariadb.service

     

    强制进行修改密码

    systemctl stop mysqld;
    
    systemctl set-environment MYSQLD_OPTS="--skip-grant-tables";
    
    systemctl start mysqld;
    
    mysql -u root;
    
    use mysql;
    
    update user set password=password('1234!@#$abc') where user='root' and host='localhost';  
    FLUSH PRIVILEGES; 

     远程授权数据库登陆:

    grant all privileges on *.* to 'root’@’192.168.4.14’ identified by ‘1234!@#$abc’ with grant option;
    
    grant all privileges on *.* to 'root’@’10.255.3.3’ identified by ‘1234!@#$abc’ with grant option;

     

     

     

     

  • 相关阅读:
    hdu 4504 dp问题 转化能力不够 对状态的转移也是不够
    BZOJ_2594_[Wc2006]水管局长数据加强版_LCT
    BZOJ_4530_[Bjoi2014]大融合_LCT
    BZOJ_3669_[Noi2014]魔法森林_LCT
    BZOJ_1180_[CROATIAN2009]OTOCI_LCT
    BZOJ_2631_tree_LCT
    BZOJ_3282_Tree_LCT
    BZOJ_2049_[Sdoi2008]Cave 洞穴勘测_LCT
    BZOJ_2622_[2012国家集训队测试]深入虎穴_最短路
    BZOJ_3653_谈笑风生_树状数组
  • 原文地址:https://www.cnblogs.com/haoxinchen/p/9664461.html
Copyright © 2011-2022 走看看