Linux入门教程:CentOS(linux) 下MySQL8.0.11的安装,


系统
CentOS 7.4

安装软件
MySQL8.0.11

下载MySQL yum源
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
安装yum源
yum localinstall mysql80-community-release-el7-1.noarch.rpm
更新yum源
yum clean all
yum makecache
创建Mysql账户
groupadd mysql
useradd -g mysql mysql
开始安装MySQL
yum install mysql-community-server
启动MySQL
systemctl start mysqld
查看初始化密码
cat /var/log/mysqld.log | grep password

登录MySQL
mysql -u root -p
修改初始化密码(密码一定要大小写字母+数字+符号,如:Aa-123456789)
ALTER USER 'root'@'localhost' IDENTIFIED BY 'yourpassword';
远程设置
use mysql;
update user set host='%' where user='root';
允许任何主机访问数据库
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%'WITH GRANT OPTION;
FLUSH PRIVILEGES;
允许myuser用户使用mypassword密码从任何主机连接到mysql服务器
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
允许用户myuser从ip为192.168.1.6的主机连接到mysql服务器,并使用mypassword作为密码
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'192.168.1.3'IDENTIFIED BY 'mypassword' WITH GRANT OPTION;

相关内容