// mysql启动配置脚本,当中仅仅有一个叫mysql的可运行文件 与mysql有关
/var/lib/mysql
// Mysql中的数据库存放文件夹
/var/lock/subsys/mysql
/usr/lib/mysql // 该目录下是mysql链接库
/usr/include/mysql
// mysql 头文件
/usr/share/mysql
// mysql 安装文件夹
/usr/bin
// 当中有mysql的多个可运行程序,如mysql、mysql_config_editor、mysqlcheck、mysqladmin等
四、mysql停止与重新启动
/etc/rc.d/init.d/mysql restart
/etc/rc.d/init.d/mysql stop
/etc/rc.d/init.d/mysql start
五、错误排查
[root@localhost rpm]# mysql -uroot
--出现故障
(1)报错:ERROR 1045 (28000): Access denied for user ‘root‘@‘localhost‘ (using password: NO)
--停止服务
/etc/rc.d/init.d/mysql stop
--安全模式进入mysql
[root@localhost rpm]# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[root@localhost rpm]# mysql -u root mysql
--更改username
mysql> UPDATE user SET Password=PASSWORD(‘root‘) where User=‘root‘;
mysql> FLUSH PRIVILEGES;
mysql> quit
[root@localhost rpm]# mysql -uroot -p
mysql> show databases;
(2)报错:ERROR 1820 (HY000): You must SET PASSWORD before executing this statement
--又一次设置rootpassword
mysql> SET PASSWORD = PASSWORD(‘root‘);
Query OK, 0 rows affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| test |
+--------------------+
4 rows in set (0.00 sec)
(3)navicat报错:Host ‘192.168.1.*‘ is not allowed to connect to this MySQL server
原因:mysql下user表中不同意外部链接
--暂时把port增加防火墙
firewall-cmd --permanent --zone=public --add-port=3306/tcp
systemctl restart firewalld.service
--更改host
[root@localhost rpm]# mysql -uroot -p
mysql> use mysql
mysql> select host, user from user;
+-----------------------+------+
| host | user |
+-----------------------+------+
| 127.0.0.1 | root |
| ::1 | root |
| localhost | root |
| localhost.localdomain | root |
+-----------------------+------+
4 rows in set (0.00 sec)
--更改localhost为%
mysql> update user set host = ‘%‘ where host=‘localhost‘;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> select host, user from user;
+-----------------------+------+
| host | user |
+-----------------------+------+
| % | root |
| 127.0.0.1 | root |
| ::1 | root |
| localhost.localdomain | root |
+-----------------------+------+
4 rows in set (0.00 sec)
--重新启动mysql服务
/etc/rc.d/init.d/mysql restart
至此mysql已能够正常使用!
六、开机启动
使用命令:sbin/chkconfig --list,查看启动项
使用命令:sbin/chkconfig --add mysql,将mysql加入到开机启动项中:
使用命令:sbin/chkconfig --del mysql,将mysql从启动项删除:
版权声明:本文博客原创文章,博客,未经同意,不得转载。
CentOS7下一个mysql安装
标签: