通过yum仓库安装mysql
1,下载安装包
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
2,安装mysql源
yum -y install mysql57-community-release-el7-11.noarch.rpm
3,安装mysql服务器
yum -y install mysql-community-server
4,启动mysql服务
systemctl start mysqld
systemctl status mysqld .查看状态
5,查看初始化密码
grep "password" /var/log/mysqld.log
6,mysql -uroot -p'中间跟原始密码'
如果登录不上去按修改路径添加skip-grant-tables 进入
vim /etc/my.cnf
[mysqld]
datadir=/usr/local/mysql/data
socket=/tmp/mysql.sock
[mysqld_safe]
log-error=/usr/local/mysql/data/mysql.log
pid-file=/usr/local/mysql/data/mysql.pid
systemctl stop mysqld
vim /etc/my.cnf
添加skip-grant-tables
启动服务 systemctl start mysqld
mysql -uroot -p
回车
mysql> use mysql;
mysql> update mysql.user set authentication_string=password("123456789") where user='root';
mysql> flush privileges;
mysql> exit
关闭服务,systemctl stop mysqld
把skip-grant-tables加#注释或删除
systemctl start mysqld启动服务
mysql -uroot -p进去密码已修改为123456789
此命令可以在在以后修改时生效 mysqladmin -u root -p'123456789' password '012345678'
mysqladmin -u root -p'123456789' password '' 设为空密码