# service mysqld restart Redirecting to /bin/systemctl restart mysqld.service
5. 输入mysql(没有设置用户和密码就可以直接连接)就可以连接到服务器
# mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 Server version: 5.6.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
6. 重置密码
mysql> set password for 'root'@'localhost' = password('password'); Query OK, 0 rows affected (0.00 sec)
mysql> quit
7. 用新密码重新连接MySQL
# mysql -u root -p Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 9 Server version: 5.6.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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>
8. 创建普通用户并授权(安装后默认一个账号是root,如果打算用root账户则可以不创建新用户)
mysql> grant all on openscannerstore.* to 'userName'@'localhost' identified by 'password'; mysql> flush privileges; Query OK, 0 rows affected (0.00 sec)
9. 设置任何机器都可以访问MySQL
mysql> grant all privileges on *.* to userName@"%" identified by 'password' with grant option; Query OK, 0 rows affected (0.00 sec)
# service mysqld restart Redirecting to /bin/systemctl restart mysqld.service
连接mysql查看最大连接数
mysql> show variables like 'max_connections'; +-----------------+-------+ | Variable_name | Value | +-----------------+-------+ | max_connections | 260 | +-----------------+-------+ 1 row in set (0.00 sec)