CentOS(linux) 下MySQL8.0.11的yum安裝

CentOS(linux) 下MySQL8.0.11的安裝


系統
CentOS 7.4
安裝軟件
MySQL8.0.11java


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;

報錯備註

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

解決:/etc/my.cnf 下[mysqld]後添加 skip-grant-tablesmysql

ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement

解決:刷新權限:flush privileges;linux

參考文獻:CentOS7 安裝 mysql8sql

相關文章
相關標籤/搜索