成都网站建设设计

将想法与焦点和您一起共享

mysql-community社区版安装

  • 1.安装MySQL
    rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
    rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm 
    rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm 
    rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm
  • 2.初始化
mysqld --initialize

#获取密码
grep "root@localhost" /var/log/mysqld.log |awk -F" " '{print $NF}'
#保存密码
echo -e "root\t$(grep "root@localhost" /var/log/mysqld.log |awk -F" " '{print $NF}')" >> /root/.mysql_passwd 
  • 3.修改mysql db的charset为utf-8

    成都创新互联公司专业为企业提供北林网站建设、北林做网站、北林网站设计、北林网站制作等企业网站建设、网页设计与制作、北林企业网站模板建站服务,10多年北林做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

    cat >> /etc/my.cnf <
  • 4.启动后报错,查看日志,修改权限
#启动
]# systemctl start mysqld
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.

#查看日志,ibdata1没有写权限
vim /var/log/mysqld.log 
2018-12-26T02:51:14.894580Z 1 [ERROR] [MY-012271] [InnoDB] The innodb_system data file 'ibdata1' must be writable
2018-12-26T02:51:14.894641Z 1 [ERROR] [MY-012278] [InnoDB] The innodb_system data file 'ibdata1' must be writable
#修改所有mysql目录及文件属主为mysql
chown -R mysql. /var/lib/   mysql*
#再次启动,成功
systemctl start mysqld 
#查看状态
]# systemctl status mysqld
?.mysqld.service - MySQL Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Wed 2018-12-26 10:57:21 CST; 4min 11s ago
  • 5.数据库管理
-- 创建账号、分配权限
CREATE USER 'user'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'localhost' WITH GRANT OPTION
-- 修改密码,使数据库可以连接Navicat
ALTER USER 'user'@'%' IDENTIFIED WITH mysql_native_password BY 'password';
-- 刷新权限
FLUSH PRIVILEGES;
-- 显示账号及权限相关信息
SHOW GRANTS FOR 'user'@'localhost'; 
    1. redis安装
      • https://redis.io/download

文章标题:mysql-community社区版安装
文章源于:http://chengdu.cdxwcx.cn/article/gidehe.html