[root@db02 /server/tools]# cd /application/ [root@db02 /application]# ln -s mysql-5.7.26-linux-glibc2.12-x86_64/ mysql [root@db02 /application]# ll lrwxrwxrwx 1 root root 36 12月 16 22:45 mysql -> mysql-5.7.26-linux-glibc2.12-x86_64/ drwxr-xr-x 9 root root 129 12月 16 22:42 mysql-5.7.26-linux-glibc2.12-x86_64 [root@db02 /application]# useradd mysql -s /sbin/nologin -M
设置环境变量
1 2 3 4
[root@db02 /application]# echo "export PATH=/application/mysql/bin:$PATH" >>/etc/bashrc [root@db02 /application]# . /etc/bashrc [root@db02 /application]# mysql -V mysql Ver 14.14 Distrib 5.7.26, for linux-glibc2.12 (x86_64) using EditLine wrapper
2019-12-16T16:00:18.247724Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option
[root@db02 /application]# cd /application/mysql/support-files/ [root@db02 /application/mysql/support-files]# ll 总用量 24 -rw-r--r-- 1 mysql mysql 773 4月 13 2019 magic -rwxr-xr-x 1 mysql mysql 1061 4月 13 2019 mysqld_multi.server -rwxr-xr-x 1 mysql mysql 894 4月 13 2019 mysql-log-rotate -rwxr-xr-x 1 mysql mysql 10576 4月 13 2019 mysql.server
启动命令:
1 2 3 4 5 6 7 8 9 10
[root@db02 /application/mysql/support-files]# ./mysql.server start Starting MySQL.Logging to '/data/mysql/data/db02.err'. . SUCCESS! [root@db02 /application/mysql/support-files]# ./mysql.server stop Shutting down MySQL.. SUCCESS! [root@db02 /application/mysql/support-files]# ./mysql.server restart ERROR! MySQL server PID file could not be found! Starting MySQL. SUCCESS! [root@db02 /application/mysql/support-files]# ./mysql.server status SUCCESS! MySQL running (1526)
sys-v方式启动:
1 2 3 4
[root@db02 /etc/init.d]# cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld [root@db02 /etc/init.d]# service mysqld restart Shutting down MySQL.. SUCCESS! Starting MySQL. SUCCESS!
[root@db02 ~]# mysqladmin -u root -p原来的密码 password 591740 Enter password: mysqladmin: [Warning] Using a password on the command line interface can be insecure. Warning: Since password will be sent to server in plain text, use ssl connection to ensure password safety. <==警告:你的密码不安全,让人看见了都。
[root@db02 ~]# mysqld_safe --skip-grant-tables --skip-networking & [root@db02 ~]# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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'forhelp. Type '\c' to clear the current input statement.
mysql> alter user root@'localhost' identified by '1'; #维护模式不允许执行此命令 ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement mysql> flush privileges; #刷新权限 Query OK, 0 rows affected (0.00 sec)
mysql> alter user root@'localhost' identified by '1'; #执行成功 Query OK, 0 rows affected (0.00 sec)
关闭数据库,并正常启动。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
[root@db02 ~]# systemctl restart mysqld [root@db02 ~]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.7.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2019, 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'forhelp. Type '\c' to clear the current input statement.