前言
之前一直没有在服务器上折腾过MysqL,今天领导让我在服务器上装一个MysqL,我心想这还不小菜一碟,谁知道这都花费了一天时间,哎,惭愧啊!记录备忘一下.
步骤
@H_404_7@shell
wget https://repo.MysqL.com//MysqL57-community-release-el5-7.noarch.rpm
shell
yum localinstall -y MysqL57-community-release-el5-7.noarch.rpm
shell
yum install -y MysqL-community-server
shell
service MysqLd start
shell
chkconfig MysqLd on
shell
grep "temporary password" /var/log/MysqLd.log
通过 MysqL -u root -p 命令来登录我们的MysqL数据库,通过上一步的密码登陆,然后修改MysqL,root密码:
shell
SET PASSWORD = PASSWORD('你的新密码');
不过需要注意的是现在MysqL已经强制要求强密码,已经不能再用弱密码比如“123456”了。如果你设置的密码过于简单,会提示错误:
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
@H_404_7@先关闭MysqL(service MysqLd stop),打开配置文件(默认为/etc/my.cnf ):
[client]
default-character-set=utf8 [MysqL] default-character-set=utf8 [MysqLd] init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake
默认的root账户只能通过localhost访问,可以添加一个账户,命令如下:
shell
GRANT ALL PRIVILEGES ON *.* TO 'new_user'@'%' IDENTIFIED BY 'new_password' WITH GRANT OPTION;
参考资料
Centos 7 yum 安装 mysql5.7
Linux学习之CentOS(十三)–CentOS6.4下Mysql数据库的安装与配置
MySQL 5.7以上 root用户默认密码问题
LINUX启动/重启/停上MYSQL的命令
mysql中通过my.cnf设置默认字符集utf-8