centos7
安装mysql
- 安装命令
#yum install mysql
#yum install mysql-devel
#wget http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
#rpm -ivh mysql57-community-release-el7-10.noarch.rpm
#yum install mysql-community-server
数据库操作
- 启动mysql
#systemctl start mysqld.service
- 查看mysql状态
#systemctl status mysqld.service
- 重启mysql
#service mysqld restart
- 获取数据库密码
#grep "password" /var/log/mysqld.log
- 登录mysql
#mysql -uroot -p
- 查看mysql默认密码复杂度
mysql>show variables like 'validate_password%';
- 修改密码校验规则(可不改)
示例:校验登记改为低,长度改为5
mysql>set global validate_password_policy=LOW;
mysql>set global validate_password_length=5;
- 修改密码
mysql>alter user 'root'@'localhost' identified by 'new password';
- 开启mysql的远程访问
mysql>grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
mysql>flush privileges;
数据库设置
配置编码格式
#vi /etc/my.cnf
进入文件后,新增四行代码:
修改完之后重启mysql