span nologin utf 目录 mysql启动 art style 开机启动
RHEL7.3 install mysql5.7
下载并安装MySQL数据库rpm包wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpmrpm -ivh mysql57-community-release-el7-8.noarch.rpm
安装完成之后会出现两个yum源文件[[email protected] /]# ll /etc/yum.repos.d/total 16-rw-r--r--. 1 root root 1222 Mar 23 2016 mysql-community.repo-rw-r--r--. 1 root root 1236 Mar 23 2016 mysql-community-source.repo-rw-r--r--. 1 root root 358 May 28 21:40 redhat.repo-rw-r--r--. 1 root root 59 May 28 21:36 rhel73.repo
新建mysql用户[[email protected] /]# groupadd mysql[[email protected] /]# useradd -r -g mysql -p root mysql[[email protected] /]# usermod -s /sbin/nologin mysql
查看系统中默认安装的MariaDB并卸载[[email protected] /]# rpm -qa|grep mariadbmariadb-libs-5.5.52-1.el7.x86_64[[email protected] /]# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
使用下载的MySQL源安装MySQL数据库[[email protected] /]# yum install mysql-server
查看MySQL启动脚本路径[[email protected] /]# which mysqld/usr/sbin/mysqld
确保数据库目录与文件的所有者为mysql账户,以便在运行mysqld服务时对这些目录和文件有读取与写入权限。以root身份运行mysqld服务,需指定--user=mysql选项。[[email protected] /]# /usr/sbin/mysqld --initialize --user=mysql使用--initialize会为root账户生成一个随机的初始密码,这个密码可用使用cat /var/log/mysqld.log | grep password查看到。使用--initialize-insecure不会为root账户生成一个随机的初始密码,可以使用mysql -u root --skip-password直接登录MySQL。[[email protected] packages]# cat /var/log/mysqld.log|grep password2017-05-28T17:01:34.663562Z 1 [Note] A temporary password is generated for [email protected]: q7yDk-yTuZEw
查看MySQL状态[[email protected] /]# systemctl status mysqld
启动MySQL[[email protected] /]# systemctl start mysqld
开机启动MySQL[[email protected] /]# systemctl enable mysqld
修改密码[[email protected] /]# mysql_secure_installation#[[email protected] /]# mysqladmin -uroot -p oldpasswd newpasswd
登录MySQL[[email protected] /]# mysql -u root -p
添加Mysql用户mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;mysql> GRANT ALL ON zabbix.* TO [email protected] IDENTIFIED BY ‘zabbix‘;mysql> flush privileges;
RHEL7.3安装mysql5.7
来源: http://www.bubuko.com/infodetail-2092862.html