centos7安装数据库步骤
首先两种安装方式,第一种通过yum源安装mariadb;第二种通过安装mysql;
- yum -y install mysql
- yum -y install mariadb-server
- mysql_secure_installation 设置 root密码等相关
当出现ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
把这个/var/lib/mysql路径下清空;
systemctl start mysqld.service
systemctl status mysqld.service
当出现Failed to start mysqld.service: Unit mysqld.service failed to load: No such file or directory
systemctl start mariadb.service
systemctl enable mariadb.service
强制进行修改密码
1、systemctl stop mysqld;
2、systemctl set-environment MYSQLD_OPTS="--skip-grant-tables”;
3、systemctl start mysqld;
4、mysql -u root;
5、use mysql;
6、update user set password=password('1234!@#$abc') where user='root' and host='localhost';
6、FLUSH PRIVILEGES;
grant all privileges on *.* to 'root’@’192.168.4.14’ identified by ‘1234!@#$abc’ with grant option;
grant all privileges on *.* to 'root’@’10.255.3.3’ identified by ‘1234!@#$abc’ with grant option;