linux
四个步骤:
安装
wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install -y mysql-server
systemctl start mysqld #启动MySQL
设置密码
grep 'temporary password' /var/log/mysqld.log
mysql -u root -p
set global validate_password_policy=0; --修改密码策略
set password=password("yourpassword"); -- tao123456.
-- 下次可以使用如下命令登录
mysql -uroot -ptao123456.
设置远程登录
-- 数据库名.表名 如果写成.代表授权所有的数据库
grant all privileges on 数据库名.表名 to 创建的用户名(root)@"%" identified by "密码";
-- 刷新刚才的内容
flush privileges;
-- 例如
grant all privileges on . to root@"113.64.243.1" identified by "123456789"; -- Tao1234432156.
设置编码
vi /etc/my.cnf
#添加
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
#重启MySQL服务,并验证
systemctl restart mysqld
mysql -uroot -ptao123456.
show variables like 'character%';
其他配置
systemctl stop mysqld #关闭MySQL
systemctl restart mysqld #重启MySQL
systemctl status mysqld #查看MySQL运行状态
systemctl enable mysqld #设置开机启动
systemctl disable mysqld #关闭开机启动
参考资料:
- CentOS7下安装mysql5.7
- 设置密码太简单导致的错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements