首页 > 数据库 > MySQL > 正文

centos7安设单节点mysql

2024-07-24 12:35:00
字体:
来源:转载
供稿:网友
      centos7安设单节点mysql:

  1、查看下面包是否安装,有安装的话卸载
 
  # rpm -qa | grep mariadb
 
  # rpm -qa | grep postfix
 
  # rpm -ev postfix-2.10.1-6.el7.x86_64
 
  # rpm -ev mariadb-libs-5.5.44-2.el7.centos.x86_64
 
  2、创建用户和组
 
  # groupadd mysql
 
  # useradd -g mysql mysql
 
  3、解压
 
  # tar -zxf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz
 
  # mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql
 
  4、修改配置文件
 
  #  cd /usr/local/mysql/support-files
 
  # cp my-default.cnf /etc/my.cnf
 
  # vi /etc/my.cnf
 
  [mysql]
 
  default-character-set=utf8
 
  [mysqld]
 
  default-storage-engine=INNODB
 
  character_set_server=utf8
 
  pid_file=/data/mysql/mysql.pid
 
  expire_logs_days=15
 
  innodb_buffer_pool_size=8G
 
  innodb_log_file_size=256M
 
  innodb_flush_method=O_DIRECT
 
  max_connections=500
 
  innodb_autoextend_increment=128
 
  basedir = /usr/local/mysql
 
  datadir = /data/mysql/data
 
  sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
  
  如果出错:
 
  mysql> update mysql.user set authentication_string=password('自定义密码') where user='root';
 
  ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
 
  mysql> SET PASSWORD = PASSWORD('自定义密码');
 
  Query OK, 0 rows affected, 1 warning (0.00 sec)
 
  mysql> ALTER USER 'root'@'localhost' PASSWORD EXPIRE NEVER;
 
  Query OK, 0 rows affected (0.00 sec)
 
  mysql> flush privileges;
 
  Query OK, 0 rows affected (0.00 sec)

(编辑:武林网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表