Centos7安装mysql社区版
1.访问https://dev.mysql.com/downloads/repo/yum/ 获取mysql yum source
wget wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
2.安装mysql80-community yum source
sudo yum localinstall mysql80-community-release-el7-3.noarch.rpm
3.使用yum 安装 mysql-server 安装80版本,切版本请访问https://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
sudo yum install mysql-server -y
4.启动mysql server 服务
sudo systemctl start mysqld
5.检查mysql服务
sudo systemctl status mysqld
6.启用mysql自启动
sudo systemctl enable mysqld
7.初次或重新安装请查找临时密码
sudo grep 'temporary password' /var/log/mysqld.log
8.运行安全脚本,输入临时密码,并修改密码为1qaz@WSX
sudo mysql_secure_installation
9.版本检查
mysqladmin -u root -p version
10.创建用户和库
mysql -u root -p
创建库
mysql>create database testdb;
创建用户
mysql>create user test IDENTIFIED by 'zxc123';
授权给用户
mysql>GRANT ALL PRIVILEGES ON testdb.* TO test@'%';
检查用户权限
mysql>use mysql;
mysql>select user,host from user;
更新权限
mysql>FLUSH PRIVILEGES;
退出
mysql>\q
11.修改/etc/my.cnf bindaddr = 0.0.0.0
12.重启mysql
sudo systemctl restart mysql