安装MySQL5.7
wget -i -c http://dev.mysql.com/get/mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql57-community-release-el7-10.noarch.rpm
yum -y install mysql-community-server
开启MySQL服务
开启MySQL服务
systemctl start mysqld
查看MySQL状态
systemctl status mysqld
登陆MySQL
查看原始密码
grep "password" /var/log/mysqld.log
登陆
mysql -uroot -p
修改新密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'new password';
允许root远程连接(不推荐)
use mysql;
UPDATE user SET Host='%' WHERE User='root';
flush privileges;
设置允许远程连接的账号(推荐)
GRANT ALL PRIVILEGES ON *.* TO '用户名'@'%' IDENTIFIED BY '密码' WITH GRANT OPTION;
修改默认编码格式
vim /etc/my.cnf
添加以下内容
[mysqld]
character-set-server=utf8
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
重启MySQL
systemctl restart mysqld
查看编码格式
mysql> show variables like 'character%';
网友评论