安装rpm包mysql数据库
yum -y install mysql* yum -y install mysql mysql-server
mysql服务管理
systemctl enable mysqld.service start stop restart
[root@iZ8vb9nmgwljcf9m2wxaekZ ~]# systemctl enable mysqld.service Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
查看状态
systemctl status mysqld.service
查看进程
pstree |grep mysqld [root@iZ8vb9nmgwljcf9m2wxaekZ ~]# systemctl start mysqld.service [root@iZ8vb9nmgwljcf9m2wxaekZ ~]# pstree |grep mysqld |-mysqld---38*[{mysqld}]
查看端口
netstat -tunpl|grep mysqld [root@iZ8vb9nmgwljcf9m2wxaekZ ~]# netstat -tunpl|grep mysqld tcp6 0 0 :::3306 :::* LISTEN 6524/mysqld tcp6 0 0 :::33060 :::* LISTEN 6524/mysqld
第一次登录没有密码
[root@iZ8vb9nmgwljcf9m2wxaekZ ~]# mysql -uroot -p Enter password:
修改密码
mysqladmin -uroot -p123 password '234'; set password ='345'; alter user 'root'@'localhost' identified by '456';
破解mysql密码
1)修改配置文件
vi /etc/my.conf.d/mysql-server.cnf
skip-grant-tables
2) 重启服务
systemctl restart mysqld
3) 空密码登录
mysql -u root -p
4) update把root密码改为空
update user set authentication_string = '' where user='root';
5) 删除skip-grant-tables
vi /etc/my.cnf.d/mysql-server.cnf
#skip-grant-tables
6)重启服务
systemctl restart mysqld
7)修改mysql密码
1) mysqladmin -uroot -p123 password '234';
2) set password ='345';
3) alter user 'root'@'localhost' identified by '456';
8.修改配置文件
vi /etc/my.cnf/mysql-server.cnf
port = 3000
systemctl restart msyqld.service