Centos7虚拟机首次安装后配置MYSQL(超详细)

测试连接
  1. 修改网卡配置,文件位置 /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
BOOTPROTO=dhcp //启动地址协议=使用dhcp协议
DEFROUTE=yes //将该接口设置为默认路由
NAME=ens33 //网络连接名字
DEVICE=ens33 //网卡名称
  1. 修改完重启
# systemctl restart network
# ip a 
  1. 测试与外界是否连通
安装界面
# yum -y groups install "GNOME Desktop"

//下次自动启动
# systemctl set-default graphical.target
# reboot

安装Mysql

# yum install -y mysql
  • 使用service启动
# service mysql start
  • 安装wget
# yum -y install wget
  • 下载mysql的repo源
# wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

# rpm -ivh mysql-community-release-el7-5.noarch.rpm 
  • 启动mysql
# yum install mysql-sever

# systemctl status mysqld

# systemctl enable mysqld #开机自启动

# systemctl start mysql

# systemctl status mysqld #查看mysqld状态
  • 查看默认密码
# grep "password" /var/log/mysqld.log
  • 登录mysql
# mysql-u root - p //输入默认密码
  • 修改密码(此时密码太简单不能通过)
mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘新密码‘;
  • 查看密码权限
mysql> SHOW VARIABLES LIKE ‘validate_password%‘;
  • 简单密码不能通过的原因是mysql有完整的初始密码规则
mysql> SHOW VARIABLES LIKE ‘validate_password%‘;
+--------------------------------------+-------+
| Variable_name                        | Value |
+--------------------------------------+-------+
| validate_password_check_user_name    | OFF   |
| validate_password_dictionary_file    |       |
| validate_password_length             | 4     |
| validate_password_mixed_case_count   | 1     |
| validate_password_number_count       | 1     |
| validate_password_policy             | LOW   |
| validate_password_special_char_count | 1     |
+--------------------------------------+-------+
7 rows in set (0.01 sec)
  • 修改密码权限
mysql> set global validate_password_policy=0;
mysql> set global validate_password_length=1;

mysql> ALTER USER ‘root‘@‘localhost‘ IDENTIFIED BY ‘r00t‘; //此时可以修改为较简单密码
  • 开始使用mysql
grant all privileges on . to ‘test‘@‘%‘ identified by ‘test‘;
···

Centos7虚拟机首次安装后配置MYSQL(超详细)

上一篇:leetcode-罗马数字转整数


下一篇:SQLServer表变量对IO及内存影响测试