大家好今天,整理一下mysql进入安全模式
因为出了好多错误,也和大家说一下
1.首先要先关闭mysql
killall -9 mysqld 这个命令是关闭所有的mysqld的进程
systemctl stop mysqld 这个命令是关闭mysqld进程
2.开启mysql安全模式,以安全模式登录
mysql_safe --skip-grant-tables & 这个命令要注意,我在网上查了好多资料,都是这个命令但是执行就会报错
[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysql_safe --skip-grant-tables &
[1] 5604
[root@iZuf63tzd3n3bigldlyfnpZ bin]# -bash: mysql_safe: command not found
^C
[1]+ Exit 127 mysql_safe --skip-grant-tables
它报错找不到 mysql_safe 这个命令,我以为这个命令要下载,经过查阅资料发现,这是mysql自带的命令
路径不对所以给它加了一个软连接
ln -s /usr/local/mysql/bin/mysqld_safe /usr/bin
有时候他会报错:因为他已经有在bin目录下边
3.执行命令
一定要看清楚命令,第一次报错就是因为命令写错了
mysqld_safe --skip-grant-tables &
如果报错就进入bin目录下执行
[root@iZuf63tzd3n3bigldlyfnpZ bin]# pwd
/usr/bin
[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysqld_safe --skip-grant-tables &
[1] 5619
[root@iZuf63tzd3n3bigldlyfnpZ bin]# 210728 11:51:20 mysqld_safe Logging to '/usr/local/mysql/var/iZuf63tzd3n3bigldlyfnpZ.err'.
210728 11:51:20 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/var
#这里直接回车
这是代表你已经执行成功了
[root@iZuf63tzd3n3bigldlyfnpZ bin]# mysql -uroot -p
Enter password: #这里直接按回车就行了
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.5.62-log Source distribution
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
仔细的去看命令能节省好多时间,如果没看出来我错在哪里:我标一下