这里写一个重置linux mysql 数据库的一套操作,非必要条件下,建议不要使用,或者使用前请做好数据备份,或者请深入研究mysql避免这样的操作。
删除 mysql 根目录下的data 文件夹下的所有数据,重置MySQL
612 rm -rf ./*
613 cd ..
615 cd bin/
617 mysqld --initialize --user=mysql
618 mysql_ssl_rsa_setup
619 cp support-files/mysql.server /etc/init.d/mysql
620 cd ..
622 cp support-files/mysql.server /etc/init.d/mysql
623 chkconfig --add mysql
624 source /etc/profile
625 service mysql start
626 mysql -u root -p
其他的如修改密码,请参考我的另一篇博文:https://blog.csdn.net/shunzi2016/article/details/9052223
另外附上基础简单的linux mysql 的my.cof
[client]
port=3306 # 设置mysql客户端连接服务端时默认使用的端口
default-character-set=utf8
socket=/data/soft/mysql-8.0.12-el7-x86_64/data/mysql.sock
[mysqld]
basedir=/data/soft/mysql-8.0.16-linux-glibc2.12-x86_64 # 设置mysql的安装目录
datadir=/data/soft/mysql-8.0.16-linux-glibc2.12-x86_64/data
socket=/data/soft/mysql-8.0.16-linux-glibc2.12-x86_64/data/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mariadb according to the
# instructions in http://fedoraproject.org/wiki/Systemd
[mysqld_safe]
log-error=/data/log/mysql-log/error.log
pid-file=/data/soft/mysql-8.0.16-linux-glibc2.12-x86_64/data/mysql.pid
#
# include all files from the config directory
#
!includedir /etc/my.cnf.d