centos7 安装mysql
1.源安装
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm sudo rpm -ivh mysql-community-release-el7-5.noarch.rpm yum update sudo yum install mysql-server sudo systemctl start mysqld
2.文件安装
#解压 tar -zxvf mysql-5.1.61.tar.gz #增加用户和组 groupadd mysql useradd -s /sbin/nologin -M -g mysql mysql #安装相关软件 yum -y install gcc yum -y install gcc-c++ yum -y install ncurses-devel #编译 ./configure --prefix=/usr/local/mysql make make install #拷贝配置及服务 cd /usr/local/mysql/share/mysql/ cp my-medium.cnf /etc/my.cnf cp mysql.server /etc/init.d/mysqld #初始化数据库 cd /usr/local/mysql/bin/ ./mysql_install_db vi /etc/my.cnf #[mysqld]下增加配置 log-error=/var/log/mysqld.log default-character-set=utf8 general_log = 1 general_log_file=/var/log/mysqld_general_log.log vi /etc/profile #增加环境变量 export PATH=$PATH:/usr/local/mysql/bin #环境变量生效 source /etc/profile #添加文件夹权限 chown mysql:mysql /usr/local/mysql/ -R #启动服务 service mysqld start #初始化root密码 mysql -uroot DELETE FROM mysql.user WHERE user=''; UPDATE mysql.user set password=PASSWORD('cO6Yt6Rs') where User='root'; FLUSH PRIVILEGES; #授权用户 mysql -uroot -pcO6Yt6Rs GRANT ALL PRIVILEGES ON *.* TO 'admin'@'58.100.%.%' IDENTIFIED BY 'rqXHR8we'; GRANT ALL PRIVILEGES ON *.* TO 'admin'@'125.210.%.%' IDENTIFIED BY 'rqXHR8we'; FLUSH PRIVILEGES;