linux系统服务命令:
systemctl start mysqld
systemctl stop mysqld
systemctl stop firewalld.service
systemctl status firewalld.service
修改mysql8安装时设置的一个非常长的密码:
mysql -u root -p
use mysql;
SHOW VARIABLES LIKE 'validate_password.%';
set global validate_password.policy=0;
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
添加用户,分配权限:
CREATE DATABASE dbtest;
CREATE DATABASE dbtest CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'user'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON dbtest.* TO 'user'@'%' WITH GRANT OPTION;
grant all privileges on dbtest.* to 'user'@'localhost' identified by 'password' with grant option;
grant all privileges on dbtest.* to 'user'@'1' identified by 'password' with grant option;
set password for 'user'@'%' password('password');
update user set password=password('password') where user='user' and host='%';
show grants;
show grants for 'user'@'%';
REVOKE ALL PRIVILEGES, GRANT OPTION FROM user;
revoke delete on *.* from 'user'@'%';
flush privileges;
更改mysql默认数据目录:
select @@datadir;
rsync -av /var/lib/mysql /mnt/volume-nyc1-01
mv /var/lib/mysql /var/lib/mysql.bak
/etc/my.cnf
datadir=/mnt/volume-nyc1-01/mysql
socket=/mnt/volume-nyc1-01/mysql/mysql.sock
[client]
port=3306
socket=/mnt/volume-nyc1-01/mysql/mysql.sock
关闭selinux:
getenforce
setenforce 0
centos7开机自启动
systemctl enable mysqld
systemctl list-unit-files | grep mysql
centos7以前开机自启动
chkconfig --list httpd
chkconfig --level 2345 httpd on
chkconfig httpd off
service httpd status
centos回滚升级(centos Downgrade or Rollback Updates)
sudo yum history
sudo yum history list
sudo yum history info
sudo yum history undo 11
相关链接:
https://dev.mysql.com/doc/refman/8.0/en/validate-password-options-variables.html
https://www.itzgeek.com/how-tos/linux/centos-how-tos/how-to-install-mysql-5-78-0-on-centos-76-rhel-76-fedora-272625.html